we can SSH Linux or login between two linux based machine without password, there are many mechanism to optin this feature in linux , illustration below is of one of the method, very quick and very easy i.e using SSH -keygen
ssh-keygen – creates the public and private keys.
ssh-copy-id – copies the local-host’s public key to the remote host’s authorized_keys file. ssh-copy-id also assigns proper permission to the remote-host’s home, ~/.ssh, and ~/.ssh/authorized_keys.
Idea is to do remote login (from machine 1 i.e your machine) to other machine (machine 2), some prerequisite for the ssh are as
- Ping should be available between two machines
- the ssh port should be enables and opened
- check for firewall if the the firewall is stopping for any remote login then we need to configure firewall accordingly.
- manually do ssh with prompt password to verify ssh is working good and if all the points above are verified then follow below steps
Steps followed for SSH in linux :
Step 1: using ssh -keygen
Create public and private key using ssh-keygen on ur machine 1
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
Copy the public key as created to remote machine 2
root@inertiagroups:~# ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
ssh: Could not resolve hostname remote-host: Name or service not known
root@inertiagroups:~# ssh-copy-id -i ~/.ssh/id_rsa.pub machine2-IP
Now try logging into the machine, with “ssh ‘IP‘”, and check in:
to make sure we haven’t added extra keys that you weren’t expecting.
* replace machine2 IP with your Machine 2 IP
you are done doing the settings for the login without password in linux base system.
Try login from your machine 1 to machine 2 using command
root@inertiagroups:~# ssh machine2-IP
Last login: Sun May 15 00:21:35 2016 from 22.214.171.124
[root@server1 ~]# [prompt of machine2]
we could login without any password requirement.