Ubuntu – How migrate the keyring (containing ssh passprases, nautilus remote filesystem, pgp passwords) and network manager connections

12.0412.10backupkeyringsnetwork-manager

Old keyring

I changed the disk on my laptop and installed Ubuntu on the new disk. Old disk had 12.04 upgraded to 12.10 on it. Now I want to copy my old keyring with WiFi passwords, ftp passwords for nautilus and ssh key passphrases.

I have the whole data from the old disk available (is now a USB disk and I did not delete the old data yet or do anything with it – I could still put it in the laptop and boot from it like nothing happened). On the new disc that is now in my laptop, I have installed 12.10 with the same password, user-id and username as on the old disk. Then I copied a few important config files from the old disk (e.g. ~/.firefox/, ~/.mozilla, ~/.skype and so on, which all worked fine… except for the key ring:

The old methods of just copying ~/.gconf/... and ~/.gnome2/keyrings won't work. Did I miss something?

New empty keyring even after copying .gnome2


1. Edit: I figure one needs to copy files not located in the users home directory as well. I copied the whole old /home/confus (which is my home directory) to the fresh install to no effect. That whole copy is now reverted to the fresh install's home directory, so my /home/confus is as it was the after fresh install.


2. Edit: The folder /etc/NetworkManager/system-connections seems to be the place for WiFi passwords. Could be that /usr/share/keyrings is important as well for ssh keys – that's the only sensible thing that a search came up with:

find /usr/ -name "*keyring*

3. Edit: Still no ssh and ftp passwords from the keyring. What I did:

  • Convert old hard drive to usb drive
  • Put new drive in the laptop and installed fresh version of 12.10 there (same uid, username and passwort)
  • Booted from old hdd via USB and copied its /etc/NetwrokManager/system-connections, ~/.gconf/ and ~/.gnome2/keyrings, ~/.ssh over to the new disk.
  • Confirmed that all keys on the old install work
  • Booted from new disk

Result: No passphrase for ssh keys, no ftp passwords in keyring. At least the WiFi passwords are migrated.


4. Edit: Boutny! Ending soon…


5. Edit: Keyring's now in ./local/share/keyrings/. Also interesting .gnupg

Best Answer

Wifi Passwords

So as a partial solution I can confirm that migration of network manager passwords for wifi connections was successful. The procedure for network-manager passwords is:

  1. Stop network-manager:

    sudo service network-manager stop
    
  2. Copy the necessary files in /etc/NetworkManager/ with:

    sudo cp -r /BACKUPDESTINATION/etc/NetworkManager/{system-connections/,VPN} /etc/
    
  3. Restart network-manager:

    sudo service network-manager start
    

And you're done. I still haven't figured out how to copy passwords in the keyring (for ssh, gpg and remote-filesystems). It drives me mad!

Migrate keys and passwords

Finally I know, what was wrong. First of all the keys moved from the old ~/.gnome2/keyrings to the new ~/.local/share/keyrings. Probably due to the switch from Gnome to Unity. Also there seem to be additional files there, aside from the usual login.keyring and user.keystore. At least there where for me after a fresh install. Those hinder migration and I had to delete them.

As mentioned both user ID and user password on my new system matched their counterparts on the old system. If for you they don't, it might probably work to set the password on your old installation to blank (i.e. change your password to no password / empty password). Do that prior to backing up your old system.

Now here is what I did:

  1. Backup the keyfile of the fresh installation in case something goes wrong:

    mv ~/.local/share/keyrings ~/.local/share/oldkeyrings
    

    Using move also makes sure that the other new files in ~/.local/share/keyrings are not there to interfere.

  2. Copy the old keyring to the fresh installation:

    mkdir ~/.local/share/keyrings && cp -r /BACKUPDESTINATION/home/$USER/.gnome2/keyrings/{login.keyring,user.keystore} ~/.local/share/keyrings
    

    For gpg keys you'll have to copy ~/.gnupg over to the new install as well.

  3. Make sure only you can access them and own them:

    sudo chmod -R 600 ~/.local/share/keyrings/ && sudo chown -R $USER:$USER ~/.local/share/keyrings
    

    (might not be necessary)

  4. Log out and back in again