How to move wifi passwords to a new installation

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

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

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.)


  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.


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.