Setup SSH passwordless login on Rhel 7 / Centos 7/ Oracle 7 |SSH is an
open source and secure network protocol that is used to login remote
machine for execution commands and run any programs. It is also used to
transfer files securely from one system to other system over network using SCP
protocol.
Uses of SSH Protocol
- Providing secure access for users
- Providing secure file transfer
- Executing remote commands
How does SSH protocol works
The working mechanism maintains the client and server model. Client initiated the request to the server. Sever send the public keys to the client machine. After that client and server both negotiate the parameters and established a secure channel .After established secure channel user can login to the remote sever through client.
In this
article learn about the SSH password less login using
ssh keygen on the Linux server.
Assume
that we have two servers
IPaddress
of server1:192.168.56.11
IPaddress
of server2:192.168.56.12
We are going to establish the password less
connection between server 1 and
server2.First we generate public key from sever1 using ssh keygen .After
generating the public key upload the public key to sever2 into authorized file
which is located at .ssh directory and set the necessary permission .
After
completed the above step the user from sever1 will connect to server2 without
promting the password.
The whole
process demonstrate below:
Step1: Create ssh authentication keys on server1
We are going to create ssh key on server1
using the following command
ssh-keygen -t rsa
Create ssh authentication keys |
Step2: Create .ssh Directory on sever2
We access
server2 from server1 using ssh and ceate .ssh directory on server2 using the following
command
ssh root@192.168.56.12
mkdir -p .ssh
Create .ssh Directory |
Step3:Upload generated public key to
server2
We access
server2 from server1 using ssh and upload the key which is generated from
server1 to sever2 on authorized file which is located at .ssh directory
cat .ssh/id_rsa.pub |
ssh root@192.168.56.12 'cat >> .ssh/authorized_keys'
Step4:Set Permission
Set the
Permission of .ssh directory and authorized file
ssh root@192.168.56.12
"chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
Step5:Access from server1 to server2 without prompting password
After
completing all above steps when we connect to sever2 from sever1 we are not
facing any password authentication.
ssh root@192.168.56.12
ssh passwordless login |
Nice post. Keep updating Devops Online Training
ReplyDelete