This Blog is to share our knowledge and expertise on Linux System Administration and VMware Administration

Monday, December 4, 2017

SSH password less authentication between inux server by using ssh keygen

ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine.  It is intended to replace rlogin and rsh, and provide secure encrypted communications between two untrusted hosts over an insecure network.

SSH server :
SSH Remote server :

Here we are going to setup password less authentication from SSH server to SSH Remote Server.

SSH KEYGEN: ssh-keygen generates, manages and converts authentication keys for ssh.  The type of key to be generated is specified with the -t option.  If invoked without any arguments, ssh-keygen will generate an RSA key for use in SSH protocol 2      connections.

Genarate Keys on Server

[linvirtshell@nsk ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/linvirtshell/.ssh/id_rsa):
Created directory '/home/linvirtshell/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/linvirtshell/.ssh/id_rsa.
Your public key has been saved in /home/linvirtshell/.ssh/
The key fingerprint is:
SHA256:8fcOx3W45JXn3651mNDK+YvL0b3jn8382MhXRFiUQ44 linvirtshell@nsk
The key's randomart image is:
+---[RSA 2048]----+
|              .=+|
|              +o.|
|        .    E o.|
|         o   . .o|
|        S . o +o=|
|           o X O+|
|            * X *|
|           . O OO|
|            +.XO#|
[linvirtshell@nsk ~]$

Create .ssh directory on Remote Server (

Login to the server and create .ssh directory under /home/nsk
[nsk@nsk .ssh]$ mkdir .ssh
[nsk@nsk .ssh]$ ls -al | grep -i .ssh
drwx------. 2 nsk nsk  6 Dec  4 11:25 .ssh

Here .ssh should be 0700 permission, under .ssh create authorized_keys file, it should be 0600 permission.

Now copy the key  from and paste the same in authorized_keys  file in

Now login from server to as user nsk

[linvirtshell@nsk ~]$ ssh nsk@
Last login: Mon Dec  4 11:39:20 2017 from nsk
[nsk@nsk ~]$

No comments:

Post a Comment