Configuration steps for setting up ssh password-free login under linux

Prefab Condition:

Two linux hosts, the ip addresses are:

192.168.0.209

192.168.0.210

 

Desired result:

Hope that on the 209 machine can be ssh login to the 210 machine, and do not need to enter the root password.

 

 Steps:

1. Use the Xshell tool to log in to the 209 machine as the root user, and then execute the following command:

ssh-keygen -t rsa

    Press Enter three times in a row to execute successfully.

2. Use the FTP tool to log in to the /root/.ssh directory of the 209 machine as the root user, and download the id_rsa.pub file.

3. Use the FTP tool to log in to the 210 machine as the root user, and upload files to the /root directory.

4. Execute the following command five:

cat id_rsa.pub >> ~/.ssh/authorized_keys

    Under the above normal circumstances, the following message should be prompted (if not, there will be no problem, it may be that other services have created the .ssh directory, and when I execute it, it is a newly built OS):

-bash: /root/.ssh/authorized_keys: No such file or directory

 If the above error message pops up, execute the following command:

mkdir .ssh

 Then execute command five.

 

Note: Please do not switch directories at will when performing the above steps, otherwise it may fail.

5. Now let's execute the following command on 209:

[root@bogon .ssh]# ssh 192.168.0.210
The authenticity of host '192.168.0.210 (192.168.0.210)' can't be established.
RSA key fingerprint is 2f:82:61:9e:94:ea:c0:39:fb:61:5f:31:4d:d9:a6:e8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.210' (RSA) to the list of known hosts.

Last login: Sun Apr 24 09:32:23 2016 from 192.168.0.102

[root@bogon ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:A5:8B:A1  
          inet addr:192.168.0.210  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fea5:8ba1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4631 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1533 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:373980 (365.2 KiB)  TX bytes:151316 (147.7 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:F4:33:27  
          inet addr:192.168.0.104  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fef4:3327/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3240 errors:0 dropped:0 overruns:0 frame:0
          TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:255979 (249.9 KiB)  TX bytes:7144 (6.9 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2128 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2128 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3274372 (3.1 MiB)  TX bytes:3274372 (3.1 MiB)

[root@bogon ~]# exit
logout
Connection to 192.168.0.210 closed.

 

If you want 210 password-free ssh login to 209, you should know how to do it.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326677420&siteId=291194637