Quickest way to setup - KEY-BASED AUTHENTICATION: LINUX

For example, we gonna setup key-based authentication from server 192.168.x.y to 192.168.x.z
( we will use this auth for root uesr )

1). Create SSH-Kegen Keys on – 192.168.x.y

[root@192.168.x.y~] # ssh-keygen -t rsa

2). Create .ssh Directory on – 192.168.x.z

# ssh root@192.168.x.z mkdir -p .ssh
The authenticity of host '192.168.x.z (192.168.x.z)' can't be established.
RSA key fingerprint is 3x:x7:a4:e5:af:89:c5:dx:b1:3c:9d:xx:66:47:03:xx.
Are you sure you want to continue connecting (yes/no)?  "press yes"

3). Upload Generated Public Keys to – 192.168.x.z

# cat .ssh/id_rsa.pub | ssh root@192.168.x.z 'cat >> .ssh/authorized_keys'

4). Set Permissions on – 192.168.x.z

# ssh root@192.168.x.z "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

5). Now you can login 192.168.x.z without password:

[root@192.168.x.y~] # ssh root@192.168.x.z
Last login: xxxxxxxxxxxxxxxxxxxxxx from 'last login ip here'
[root@192.168.x.z ~]#

Done !!!

Comments

Popular posts from this blog

Resolved: DOCKER: Error response from daemon: Could not attach to network / rpc error: code = 7 desc = network not manually attachable.

yum failed 6 times. Cannot continue!

unexpectedly shrunk window (repaired) in dmesg log - TCP Peer