How to move wifi passwords to a new installation

19,679

Solution 1

On my 12.04 system the WiFi connections and passwords (in the clear) were stored in text files in /etc/NetworkManager/system-connections/

Stopping the network manager, copying these files to the new machine, restoring the permissions and restarting network manager worked for me.

sudo stop network-manager
sudo cp /backup/path/etc/NetworkManager/system-connections/* /etc/NetworkManager/system-connections/
sudo chown root.root /etc/NetworkManager/system-connections/*
sudo start network-manager

Solution 2

On Ubuntu 16.04, copying the files from /etc/NetworkManager/system-connections/ was not enough. The files contain the wlan interface MAC address, and I also had to correct that to make it work.

The following procedure worked for me to import the wireless configs from my old 12.04 system to the new 16.04 installation.

# Stop Network Manager
sudo /etc/init.d/network-manager stop

# copy the files from your old system (adapt as needed)
sudo rsync -va -c "/media/$YOUR_OLD_SYSTEM/etc/NetworkManager/system-connections/" /etc/NetworkManager/system-connections/

# Get your new MAC address, and verify it is right.
# For example, this should work if you have only one wireless interface
export MAC=$(iw dev | grep addr | awk '{print $2}')
echo "$MAC"

# Replace the MAC address in all the system-connections files
sudo perl -i.bak -pe 's/^(mac-address=)(.*)/$1$ENV{MAC}/' /etc/NetworkManager/system-connections/*

# Restart NetworkManager, and wait for nm-applet to also start and connect    
sudo /etc/init.d/network-manager start

# Delete the backup files with the old MAC addresses
sudo rm /etc/NetworkManager/system-connections/*.bak

If for some reason you would like to keep the original timestamps of your system-connections files instead of the timestamp when you changed the MAC address, here is an alternative which assumes that you have 2 separate folders with your old and current connection files:

old=/etc/NetworkManager/system-connections.old
new=/etc/NetworkManager/system-connections
for f in $old/*; do b="$(basename "$f")"; perl -pe 's/^(mac-address=)(.*)/$1$ENV{MAC}/' "$f" > "$new/$b"; touch -r "$f" "$new/$b"; done

Solution 3

Your passwords are stored in ~/.gnome2/keyrings. By default, they are protected with your login password. If you copy that folder to your new system and use the same login password, then you should have all of your passwords, including your wifi connections.

Your Passwords

You can see your passwords in the Passwords and Encryption Keys application. They should be under a keyring called login. You can search for "Network secret" to show only wifi passwords.

mv ~/.gnome2/keyrings ~/old_keyrings
cp ~/backup/keyrings ~/.gnome2/keyrings

However, for network manager to use your password, it needs a gconf setting with a matching id number. You can do this two ways: copy your old gconf settings or create new connections and change their id numbers.

Copy your old gconf settings

This is really simple:

# network-manager will overwrite your changes if you don't terminate it
sudo stop network-manager
# back up old settings
mv ~/.gconf/system/networking/connections ~/old_connections
cp /media/old_install/.gconf/system/networking/connections  ~/.gconf/system/networking/connections
sudo start network-manager

Unfortunately, this method didn't work for me. My test case is abnormal, so hopefully it works for you.

Create new connections

If the above doesn't work for you, then on your old machine:

  1. open Passwords and Encryption Keys
  2. right click on your default keychain
  3. select change password
  4. set the password to blank
  5. copy the ~/.gnome2/keyrings/default.keyring to ~/old_passwords.keyring
  6. Now you can connect to networks and look up passwords in ~/old_passwords.keyring (since you removed the password, it will be a plain-text file).

(You could also create connections and modify their uuid to match the existing password, but that's too much work unless you can script it.)

Solution 4

  1. Shut down NetworkManager

    sudo /etc/init.d/network-manager stop
    pkill nm-applet
    
  2. Copy ${HOME}/.gconf/system/networking/connections/
  3. Restart network-manager:

    sudo /etc/init.d/network-manager start
    

    Press Alt+F2 and enter nm-applet --sm-disable to start the applet.

Might be a litte out of date.

Solution 5

JoliCloud is based on 10.04, so I'd assume that it is using Network Manager to organize wireless passwords. Much of that configuration is stored in .gconf/system/networking/ -- Not sure if the passwords are stored there or elsewhere.

Share:
19,679
Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I have an Acer Aspire ZG5 netbook which is currently running Jolicloud, but I've decided it isn't for me and plan to switch to Lubuntu or Xubuntu.

    However, I do lot of travelling and have many saved wifi passwords for different offices, hotels, cafes, restaurants, friends' and relatives' houses etc. It would be very annoying to have to ask for and reenter all of these passwords.

    Is there a way to transfer my saved wifi passwords from the old installation to the new one?

  • user941105
    user941105 almost 13 years
    Aren't the gconf settings only necessary if you have specific settings for different networks (you used network manager to edit your connection to change MTU, DHPC settings, etc...). All my passwords are stored in my keyring.
  • con-f-use
    con-f-use almost 13 years
    Last time I checked, both was necessary.
  • user941105
    user941105 almost 13 years
    Yes, you're right. network-manager doesn't bother to look in the keychain unless there's a matching uuid in the gconf settings.
  • con-f-use
    con-f-use almost 13 years
    nice of you to elaborate on my earlier post.
  • Kangarooo
    Kangarooo almost 12 years
    Xubuntu doesnt have .gconf/system/networking/connections
  • Marc
    Marc over 8 years
    Does not work on 14.04
  • conualfy
    conualfy over 7 years
    Works perfect also on Ubuntu 16.04 to 16.10. I copied the files from 16.04 and restored the passwords in 16.10, they appear in the Network Manager after a session restart (did not try the stop/start network-manager, could also work). Don't have the wifi networks to actually see if they connect automatically, but as they appear over there, they should also connect.
  • conualfy
    conualfy over 7 years
    Works also to stop/start the network-manager service if you use: sudo /etc/init.d/network-manager start (or stop)
  • Pablo Bianchi
    Pablo Bianchi over 6 years
    start/stop use initctl to communicate with Upstart init daemon. Use the systemd way: sudo systemctl stop NetworkManager.service.
  • Ajith Kumar
    Ajith Kumar about 4 years
    Works in Ubuntu 19.10 (replace the first and fourth command mentioned above as follows: sudo /etc/init.d/network-manager stop sudo /etc/init.d/network-manager start
  • Pablo Bianchi
    Pablo Bianchi over 3 years
    You can combine grep with awk with iw dev | awk '/addr/ {print $2}'. Maybe more modern would be to use systemctl stop network-manager.service.
  • SpinUp __ A Davis
    SpinUp __ A Davis about 3 years
    Still works great in 20.04, wifi network immediately connected after restarting network manager, although I use sudo service network-manager stop and then later with start; good to know there's so many ways to control system services...