Ssh key is very useful if you want to login quickly into applications such as when you want to clone or push from/to Github. Imagine if you set up this ssh key in plenty of services and you have to reinstall the operating system…what a nightmare!
Actually there’s a very easy way to setup your ssh key with zero pain.
First of all you have to backup in a pendrive your old ~/.ssh folder.
Now, when your os is ready, copy it into ~/
If you try now to add the key running
$ ssh-add
you are promped with something like this:
So, it’s now time to change the permissions. This gist list all the permissions.
The ones requires are these:
$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/id_rsa
$ chmod 644 ~/.ssh/id_rsa.pub
after this step let’s run the following command:
$ cd ~
$ ssh-add
You will be asked for the passphrase: enter your secret key and if everything is correctly you should see something like this:
If you are doing this in the Linux Subsystem of Windows you may encounter the following error:
"Could not open a connection to your authentication agent."
In this case, run this in the terminal:
$ eval $(ssh-agent)
$ ssh-add
Finally, if you have to put the public key to a server or a vps to login, you can launch this command:
$ ssh-copy-id user@ipaddress
and then when you try to login the password is no longer required
Cheers
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.