Tuesday, 8 November 2016

Copy ssh key from one ubuntu machine to another ubuntu machine.

Tags
Accessing GIT repository or Clone with SSH we need to add our ssh public key to SSH keys list in Git profile setting https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/.

Accessing remote machine through Secure Socket Shell also we need to add our ssh public key to authorized_keys https://www.debian.org/devel/passwordlessssh.

When you are switching your old laptop to new laptop, Then you have to do all those setting again. So, Instead of doing that again we can copy our old laptop ssh key to the new machine. From that way, we can skip adding SSH keys list in Git profile setting and adding our ssh public key to authorized_keys.

Only you need some simple steps in your ubuntu. Copy existing ssh folder, it is hidden in `/home` directory as `.ssh`.
  
tar -cf ssh_backup.zip .ssh


Create dummy ssh key in new ubuntu machine.
  
ssh-keygen -t rsa -b 4096 -C "YOUR@EMAIL.com"


Copy and Extract ssh_backup.zip in the new machine, It will work without any issue. You have to use the same passphrase if you set for you old ssh_key.