Login to the server you want to connect from

Run the following command to see if existing SSH keys are present:

ls -al ~/.ssh/id_*.pub
Generate a new SSH key pair.
ssh-keygen -t rsa -b 4096

In order to be able to login to your server without a password, copy the public key to the server

ssh-copy-id remote_username@server_ip_address

Once the user is authenticated, the public key will be appended to the remote user authorized_keys file and connection will be closed.

Login to your server using SSH keys

ssh remote_username@server_ip_address

METHOD USING PUTTY

open PuttyGen.exe In the PuTTY Key Generator box, make sure the radio button at the bottom is selected for RSA.

Click the Generate button and Move your mouse around the box to help generate the keys.

Click both the Save public key and Save private key buttons that appear on the bottom right to save these keys to your computer.

Call them both MyPublicKey and MyPrivateKey respectively

Upload the public key you just created to your server into the /root/ (/home/username/) directory

Login to the server with the user you want to add the key for.

Go to your home directory

cd ~
Create an /.ssh directory if it does not exist
mkdir .ssh
chmod 700 .ssh

While still in your user's home directory, append the public key you just uploaded to a file named authorized_keys using the following command

ssh-keygen -i -f MyPublicKey >> ~/.ssh/authorized_keys

if you needed to create the authorized_keys file set the permissions on it

chmod 600 ~/.ssh/authorized_keys

Delete the public key you uploaded

rm MyPublicKey

Log out of PuTTY and start the program up again When the program restarts, open the configuration box and click the Connection > Data category on the left.

Enter your server username in the first field which is named Auto-login username.

In the same configuration box, click Connection > SSH > Auth

Click the Browse button and navigate to the location on your computer where you saved your MyPrivateKey file

On the configuration box, click the Session category and enter the following:

Host Name: hostname or IP of server
Port: 22
Connection Type: SSH
Saved Session: Enter a new name to identify this server connection

Click the Save button.

Open PuTTY and click the new saved session you created for the passwordless login, then click the Open button.

You should then be logged in without a password prompt.

Previous Post Next Post