Linux Configuration remote SSH password-free login _linux

Source: Internet
Author: User
Tags ssh

This example for you to share the Jalinux configuration remote SSH password-free login method for your reference, the specific contents are as follows

System: CentOS 6.8
Host 1:192.168.0.177
Host 2:192.168.0.178
Tools Introduction:
Ssh-keygen: Creating Public keys and keys
Ssh-copy-id: Copies the generated public key to the Authorized_keys file on the 192.168.0.178 host.
Ssh-copy-id also sets the appropriate permissions for the remote host's user home directory (/home) and/root/.ssh and/root/.ssh/authorized_key

1 Create the public key and key

[Root@test ~]# ssh-keygen-t RSA
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 PA Ssphrase again:
Your identification has been saved.
Your public key has been saved in/root/.ssh/id_rsa.pub.
The key fingerprint is:
79:a9:66:cd:1a:a5:7c:82:80:c3:06:ec:44:13:b9:7a root@test the
key ' s randomart image is :
+--[RSA 2048]----+
| +o |
| O.... | |
. O. |
| o+ ... |
| = . S + |
|.. E.. o B |
| . . O + |
| o = |
| . |
+-----------------+

[Root@test ~]#

2) Copy public key to remote host

[Root@test ~]# ls. ssh/
authorized_keys id_rsa id_rsa.pub
[root@test ~]#
[root@test ~]# ssh-copy-id-i]/root /.ssh/id_rsa.pub root@192.168.0.178 The
authenticity of host ' 192.168.0.178 (192.168.0.178) ' can ' t be established.< C5/>rsa key fingerprint is 53:bd:d7:e6:27:96:f3:70:f1:4b:4d:35:a4:38:1d:69.
Are you sure your want to continue connecting (yes/no)? YES
warning:permanently added ' 192.168.0.178 ' (RSA) to the list of known hosts.
root@192.168.0.178 ' s password: Now
try logging to the machine, with SSH ' root@192.168.0.178 ', and check in:
. Ssh/authorized_keys to make
sure we haven ' t added extra keys this you weren ' t expecting.
[Root@test ~]#

3) test Remote connection

[Root@test ~]# IP addr Show 1:lo: <LOOPBACK,UP,LOWER_UP> MTU 65536 qdisc noqueue State UNKNOWN Link/loopback 00:00  : 00:00:00:00 BRD 00:00:00:00:00:00 inet 127.0.0.1/8 Scope host lo inet6:: 1/128 scope host Valid_lft Forever Forever 2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU 1500 Qdisc pfifo_fast State up Qlen 1000 link/ether-00:0c:29 : 7e:1f:f6 BRD ff:ff:ff:ff:ff:ff inet 192.168.0.177/24 BRD 192.168.0.255 scope global eth0 Inet6 The scope link Valid_lft forever preferred_lft forever [Root@test ~]# [root@test ~]# ssh 192.168.0.178 last Login:sat Sep 14:00:49 2016 from 192.168.0.103 [root@test ~] #ip addr 1:lo: <LOOPBACK,UP,LOWER_UP> MTU 65536 QDISC noqueue Stat E UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet Scope host lo 127.0.0.1/8:: Inet6 Scope Host VA Lid_lft Forever Preferred_lft Forever 2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU 1500 Qdisc State up Qlen 1000 Link/ether 00:0c:29:36:93:06 BRD ff:ff:ff:ff:ff:ff inet 192.168.0.178/24 BRD 192.168.0.255 scope global eth0 Inet6
 306/64 scope link Valid_lft forever Preferred_lft forever

View the 192.168.0.177 generated Authorized_keys

[Root@test. ssh]# cat Authorized_keys
ssh-rsa aaaab3nzac1yc2eaaaabiwaaaqea+ i6lxde5dvsmqjcx98fpzscxogpj6fd47yxzp/tp/htpotqgnbitjh6s6ynmsd5lqlbed8a5ctx5wkm+h7rt0po2xd+azcf69js+4swo8/ xfwhlz/8o64hsvn68gmxqo9vp8giwwczny/csmoecllob1nfxpcwq1tbw+p4n84oj2yhwdszgcre8j/ oiachhl6qhftaufvodvryfeyurfm8kp6bb6teeddrqilboaqttjowrd2fkt33c5lpuznngqc+ dmrjdabgc3zgzrce3oyybharlfiwvhfpyt7pdqmnrp/dumybss/6gwd2cik3cv4zvpozygdynpqxsxiibikw== Root@test

To this trust add is done, 192.168.0.177 can telnet to the 192.168.0.178 server without password, if you want to achieve two-way trust, please 192.168.0.178
Repeat the above steps, write the purpose of this article just want to record the things, in case of forgetting to check!

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.