No Password for ssh-based communication between hosts

Source: Internet
Author: User

No Password for ssh-based communication between hosts

Node1: 172.16.58.1

Node2: 172.16.58.3

Node1 --> node2

 

First, generate a key in node1.

 

 

Run ssh-keygen-p''

If you want to save the path, press enter to default,

The private key is saved as/root/. ssh/id_rsa.

Save the public key as/root/. ssh/id_rsa.pub

[root@node1 ~]# ssh-keygen -P ''Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): 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:dc:62:ba:81:ac:dd:d9:93:fa:b4:9b:21:8d:e7:98:8c root@node1.magedu.comThe key's randomart image is:+--[ RSA 2048]----+|                 ||                 ||                 ||       . .       ||        S .      ||   . . = .       ||    o = =.       ||   o + %o+       ||  . E OoBo       |+-----------------+

Pass the key to the node2 host

 

ssh-copy-id -i .ssh/id_rsa.pub root@172.16.58.3[root@node1 ~]# ssh-copy-id -i .ssh/id_rsa.pubroot@172.16.58.3The authenticity of host '172.16.58.3 (172.16.58.3)' can'tbe established.RSA key fingerprint isdb:f8:11:fa:7d:30:95:44:1b:eb:ea:89:ee:fa:a1:27.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '172.16.58.3' (RSA) to the listof known hosts.root@172.16.58.3's password:Now try logging into the machine, with "ssh'root@172.16.58.3'", and check in:   .ssh/authorized_keys
To make sure we haven' t added extra keys thatyou weren't expecting.

Test whether password-free login is successful. No prompt is displayed for entering the password

Ssh 172.16.58.3 'date'; date

[Root @ node1 ~] # Ssh 172.16.58.3 'date'; date

Wed Dec 31 16:51:41 CST 2014

Wed Dec 31 16:52:42 CST 2014
 

 

 

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.