Generating SSH Keys on Windows PuTTY for Linux Server

0
2384

Download and Install PuTTY from below link

https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

open PuTTYgen and click on Generate

Enter password in Key passphrase and confirm passphrase.

Now click on save private key and save it.

login to Linux server shell and authorize public key in that

mkdir ~/.ssh
chmod 0700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 0644 ~/.ssh/authorized_keys

Now add your public key in ~/.ssh/authorized_keys and save it

vi ~/.ssh/authorized_keys

Copy the key from generated window

How to Login with PuTTY

Open PuTTY and Under Host Name (or IP address) enter your server IP or hostname as [email protected] or user@ipaddress

Next goto SSH tab on left hand side and click on + sign. Now click on Auth. Here in Private Key File for Authentication browser to your saved private key

Go back to session tab from left hand side options and click open. As you will now be asked for passphrase for the key file. Enter the key and you will be logged in into the server.

As you have completed the above step and you can login with your key file. Its time for disabling password authentication so that only key will be used for SSH connection.

vi /etc/ssh/sshd_config

Find

PasswordAuthentication yes

Replace

PasswordAuthentication no

Save the file and restart sshd

systemctl restart sshd

If you now try to login into the server without key file you will see the below error