

On H2, change the permission of the private key to be less accessible (otherwise next step will fail) with the command chmod 600 ~/.ssh/id_rsa, so that the output of the following command ls -alt ~/.ssh will contain the following (notice the difference from the above permission):.rw-r-r- 1 youUserName youUserName 412 Nov 3 14:52 id_rsa.pub rw-r-r- 1 youUserName youUserName 1240 Nov 3 14:52 id_rsa When you will execute the following command in H2 ls -alt ~/.ssh the output will contain at least the following: ~/.ssh/id_rsa.pub) from your H1 machine to your H2 machine in location ~/.ssh (Do this only through a trusted USB that you will format afterwards, do not use emails or any other internet-based medium). This is not advisable for security reasons as extensively mentioned by others, however, it is possible to achieve with per the following steps:
#Ssh key copy to server how to#
The problem that the questions seem to ask is how to make use of the same private-public key pair generated and used on a personal computer (H1) can be used on another personal machine (H2) so as not to have to set up a new private-public key and manually add it to each server that we used to connect to. One account on a server has a single username and any number of authorized public keys, all of them listed in the ~/.ssh/authorized_keys file.Īll the answers here address the issue of copying identity from one server to another server by making use of ssh-copy-id, which is not the point of the question.
#Ssh key copy to server password#
Public-key systems like ssh are better than the password system: People have it hammered into their head that one account on a server has a single username and, of course, a single authorized password. That can't be the right way, because everyone says that the private key is never supposed to leave the client machine.

That can't be the right way, because everyone says that public key authentication is much better than passwords.

id_rsa_foo.pub this is the public file that goes to your remote server. Two files were created: id_rsa_foo This is your key file that sits on the local machine. Next it asks to make a passphrase, it’s a password you have to type when logging in with the key. Enter file in which to save the key (/Users/bob/.ssh/id_rsa): /Users/bob/.ssh/id_rsa_foo
