How to configure SSH Key access to Linux Server using Windows (client)?

Posted Date : 07-09-2018

In this article, We’ll be explaining how to provide SSH Key authentication to the Windows User(Client) to use Linux server without using password.

Prerequisites:

1.Install Open SSH in Linux Machine

2.Install PuTTY in Windows Machine

3.Install PuTTYGen in windows to generate SSH Keys

Note : We demonstrate this task with assumption that our Linux Server running in CentOS 7 Distribution and Windows client running in Windows 10 (its applicable for other version also).Moreover, it will be same for other Linux Server distribution Ubuntu/Debian.

SSH key is a Secure shell Key, it is an access credential SSH protocol to communicate with servers. There are few different ways to login to server. Let’s see about one of the predominant way to login. It’s an extremely secure way to login to the server.

How SSH Key works (RSA Algorithm for Cryptography)?

Actually, it follows protocol of RSA algorithm encrypting process using two authentication keys to authenticate client to SSH server. SSH keys are named as Private Key and Public Key. Private Key will kept secret by the Client, at no matter this key shouldn’t be compromised with others, because attackers can easily login to the server without any further authentication. The Public key in the SSH server used to encrypt the message, which can be decrypt only by private key at the client machine.

The public key is uploaded to a remote server by logging to SSH.The key is added to special file within the user account you will be logging into called .ssh/authorized_keys

When a client attempts to login, the server check for the authentication of the client. If once the client prove their identity using private key, the shell session is spawned and the requested command is executed, else access is denied.

How to generate SSH Key?

Download and Install PuTTYGen. Then generate Private Key and Public Key by following the steps explained in figure 1.
Note : Add Key passphrase. It provide additional protection to your account.

Figure 1 : How to generation of SSH Key using PuTTYGen
How to Load Public key in server?

Step 1 : Login to the server using password as user for whom the SSH Key authentication need to be enabled.

Step 2 : You will be directed to /home/user directory.Check for .ssh file/directory in your current directory by using following commands,

cd

ls –la | grep .ssh

If you can’t find it , create the directory / .ssh

mkdir .ssh

cd .ssh/

Step 3: After step 2, you need to upload public key in the server authorized files under .ssh/authorized_key .In prior copy the Public key from PuTTYGen as shown below in figure 2,

Figure 2 : How to Copy Public Key from PuTTYGen

Now in your user terminal under the path  (# Cd .ssh/),

Type : echo (past the copied public key) >> authorization_keys

Note:  >> ; this help to append the key with the file named authorization keys

Step 4: logout the session

Step 5 : Configure to Linux/OpenSSH Server with private key using the windows (client machine) path.

Open putty terminal, under authorization and then add private key path shown in figure 3,

Figure 3 : How to add private key path for authentication in PuTTY

Step 6 : Now using PuTTY login into the server as shown in figure 4.

Enter login : root/specified username

then using key access and key passphrase login to the account (its important to note down the key passphrase).

Figure 4 : Logging to server using SSH Key access (Key & Key passphrase)

Congratulations! Now you have logged into your Linux machine using public/private key authentication.

Please feel free to provide constructive feedback. Comments are greatly appreciated !

 

Leave a Reply