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 : 10.0.0.35
SSH Remote server : 10.0.0.40
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 10.0.0.35
[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/id_rsa.pub.
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#|
+----[SHA256]-----+
[linvirtshell@nsk ~]$
Create .ssh directory on Remote Server (10.0.0.40)
Login to the server 10.0.0.40 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 id_rsa.pub key from 10.0.0.35 and paste the same in authorized_keys file in 10.0.0.40.
Now login from server 10.0.0.35 to 10.0.0.40 as user nsk
[linvirtshell@nsk ~]$ ssh nsk@10.0.0.40
Last login: Mon Dec 4 11:39:20 2017 from nsk
[nsk@nsk ~]$
Monday, December 4, 2017
SSH password less authentication between inux server by using ssh keygen
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment