How to Use SSH Key Based Login with PuTTY on Windows 10 / 7

How to Use SSH Key Based Login with PuTTY on Windows 10 / 7 / 8. There are two types of authentication with SSH connection with the server one is password based authentication and another one is a SSH key based authentication. The SSH key based authentication is most secure than traditional password based authentication. The SSH key based authentication is less Vulnerable with attacks. This the recommended step to secure your root logins to the servers. It is necessary step for sysadmins to secure your servers from external attacks. This tutorial explain how to connect your server using the SSH key based authentication using the PuTTY software on Windows OS.

Step-1 (Add a normal users to respective Linux Distribution)

On Ubuntu / Debian
[email protected]:~# adduser techbrown
On CentOS / RHEL

Add a normal user

[email protected]:~# adduser techbrown

Add a password to normal users

[email protected]:~# passwd techbrown

Step-2 (Grant sudo privileges to normal users)

On Ubuntu / Debian
[email protected]:~# gpasswd -a techbrown sudo
On CentOS / RHEL
[email protected]:~# gpasswd -a techbrown wheel

Step-3 (Generate the Public and Privates SSH keys)

[email protected]:~# ssh-keygen -t rsa
Sample Output


Step-4 (Copy the public SSH key for further use)

[email protected]:~# cat /root/.ssh/
Sample Output


Copy the above public keys to notepad for further use

Step-5 (Add the Public SSH keys to normal users)

Switch the root user to normal users

[email protected]:~# su - techbrown

Create SSH directory

[email protected]:~$ mkdir .ssh

Provide the secure 700 permissions to directory

[email protected]:~$ chmod 700 .ssh

Add the generated public keys to the file

[email protected]:~$ vi .ssh/authorized_keys
Sample Contents


Provide the secure 600 permissions to files

[email protected]:~$ chmod 600 .ssh/authorized_keys

Sign out from normal users

[email protected]:~$ exit

Step-6 (Disable the root user login using SSH)

On Ubuntu / Debian
[email protected]:~# vi /etc/ssh/sshd_config

Find the lines

PermitRootLogin yes

Change it to

PermitRootLogin no
On CentOS / RHEL
[email protected]:~# vi /etc/ssh/sshd_config

Find the lines

#PermitRootLogin yes

Change it to

PermitRootLogin no

Step-7 (Restart the SSH service to confirm changes)

Finally restart the SSH services to make the changes

[email protected]:~# systemctl restart ssh

Step-8 (Copy the Private SSH keys)

[email protected]:~# cat /root/.ssh/id_rsa
Sample Output


Step-9 (Save the Private SSH keys to notepad file)

Open notepad and save the Private SSH keys to it and save it using the .txt extension.


Step-10 (Download and Install PuTTY Software)

You can download the Putty Software package (putty-installer.msi) from the official website and install it on respective Windows OS.

Step-11 (Save SSH private keys in .ppk extension)

Open PuTTYGen from start menu


Load the saved Private SSH key saved in .txt extension


Finally save the private key into its own .ppk extension


Step-12 (SSH key based authentication using SSH private keys)

Open PuTTY from Start Menu


Select the normal users that you have created during this tutorial


Select the private SSH key file for authentication


Set the IP to Login with SSH private key based logins and finally hit on open to open the terminal


If you are successfully authenticated the you will see the terminal window shown as below.


If anyone tries with the SSH password based logins then will get the access denied information this makes your server so secure and less vulnerable to attacks.



Finally you have secured your server using SSH key based authentication login methods. This methods is useful to secure your server from external attacks and less vulnerable to attacks. If you have any issues then you need to use the comment form below.

Related Post

Develop New SysAdmin Skills with E-books (FREE Download)