1

I'm planning to do a fresh OS installation, but first I want to backup my .ssh folder in order to keep my ssh keys. Can I copy it into a usb stick and if so how can I do this? Do I need to do any extra steps in order to "restore" the ssh keys on my new installation?

ltdev
  • 597
  • 1
    @Yaron I saw this post before posting mine, but it doesn't say anything about how to do the back up (or at least I didn't understand from what I've read) – ltdev May 21 '17 at 10:35
  • @Lykos then editing you post, reflecting that you didn't understand would generate specific answers which aren't duplicates of original ones – Sumeet Deshmukh May 22 '17 at 03:46
  • 1
    @Lykos: The linked question doesn't mention how to perform the back-up and the restoration because they're a trivial copy (or archiving and extracting) of the content of that directory. – David Foerster May 22 '17 at 09:08

2 Answers2

1

how-to-set-up-ssh-keys-on-linux-unix

  1. How to backup an existing private/public key?

    Just copy files to your backup server or external USB pen/hard drive:

    • Copy files to usb pen drive mounted at /mnt/usb *

    cp -avr $HOME/.ssh/ /mnt/usb/backups/

Yaron
  • 13,173
1

For the user keys

sudo rsync -arv ~/.ssh/ /media/user/flash

where /media/user/flash is your mounted usb stick location

For the server keys

sudo rsync -arv /etc/ssh /media/user/flash

After your new set up is ready just perform the reverse.

Warning This will transfer your personal keys and your server keys (and they can be used to 'be' (not just impersonate) the old server (or you), so be careful what happens to the usb stick after you no longer require it...)

sergtech
  • 503