We can SSH Linux or log in between two Linux based machine without a password. There are many mechanisms to utilize this feature in Linux. Below is of one of the methods, which is fast and simple 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.
[bibblio style=”bib–row-3 bib–default bib–hover bib–white-label bib–font-arial bib–size-18″ query_string_params=e30=]
Idea is to do remote login (from machine 1 i.e your machine) to another machine (machine 2). Some prerequisite for the ssh are as below:
- Ping should be available between two machines
- the ssh port should be enabled and opened
- check for the firewall. if the firewall is stopping for any remote login then we need to configure firewall accordingly.
- manually do ssh with a 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 a public and private key using ssh-keygen on your 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
Settings for the login without password in Linux base system is done now.
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 184.108.40.206
[root@server1 ~]# [prompt of machine2]
we could log in without any password requirement.
give a try with this and let me know if this was helpful !!