To enable access to a remote host requiring a password, follow this procedure:

1. Generate SSH keys in the local host

# ssh-keygen -t rsa -b 2048 -N ''

This command generates 2 keys: a private (id_rsa) and a public (id_rsa.pub).

2. Install the public key in the remote host

To do this, append the contents of id_rsa.pub to ~/.ssh/authorized_keys in the remote server. You can do this using the commands below:

# ssh user@remote "test -d ~/.ssh || mkdir ~/.ssh && chmod 700 ~/.ssh"
# cat ~/id_rsa.pub | ssh user@remote "cat >> ~/.ssh/authorized_keys"

NOTE: The above commands will ask you for user’s password.

After completing both steps, you will be able to connect via ssh without asking for password using the following command:

# ssh user@remote