You may find it difficult to enter the password each time you try to SSH to the server. This article will help you to login automatically, without entering the password.
Suppose you want to login to the server Y [hostname or IP] as user y from the local host X where you are user x.
First login on the local machine X as user x and generate a pair of authentication keys. Do not enter a passphrase:
x@X:~> ssh-keygen -t rsa
Generating public/private rsa key pair. Enter file in which to save the key (/home/x/.ssh/id_rsa): Created directory '/home/x/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/x/.ssh/id_rsa. Your public key has been saved in /home/x/.ssh/id_rsa.pub. The key fingerprint is: 3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 x@X
Now use ssh to create a directory ~/.ssh as user y on Y. (The directory may already exist, which is fine):
x@X:~> ssh y@Y mkdir -p .ssh y@Y's password:
Append x’s new public key to y@Y:.ssh/authorized_keys and enter y’s password one last time:
x@X:~> cat .ssh/id_rsa.pub | ssh y@Y 'cat >> .ssh/authorized_keys' y@Y's password:
From now on you can log into Y as y from X as x without password:
x@X:~> ssh y@Y y@Y:~>
Depending on your version of SSH you might also have to do the following changes:
Put the public key in .ssh/authorized_keys2
Change the permissions of .ssh to 700
Change the permissions of .ssh/authorized_keys2 to 640