Generate a key pair on the local server

ssh-keygen

 

Output

 

Generating public/private rsa key pair.

Enter file in which to save the key (/home/user/.ssh/id_rsa):

Created directory ‘/home/user/.ssh’.

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/user/.ssh/id_rsa.

Your public key has been saved in /home/user/.ssh/id_rsa.pub.

The key fingerprint is:

 

8c:2a:ed:82:98:6d:12:0a:3a:ba:b2:1c:c0:25:be:5b

Install your public key on the remote server

ssh-copy-id -i ~/.ssh/id_rsa.pub UserName@RemoteServer

 

Output

 

UserName@RemoteServer’s password: ********

Now try logging into the machine, with «ssh ‘username@remoteserver'», and check in:

~/.ssh/authorized_keys

 

to make sure we haven’t added extra keys that you weren’t expecting.

Add a private key to the authentication agent on the local server

ssh-add

 

Output

 

 

Identity added: /home/user/.ssh/id_rsa (/home/user/.ssh/id_rsa)

Now you can log into the remote server via the SSH protocol without prompting a password.