How to set up SSH password-free logon on CentOS/RHEL

Source: Internet
Author: User
Tags ssh centos free ssh

The following steps are successfully tested on CentOS 5/6/7, RHEL 5/6/7, and Oracle Linux 6/7.

Node 1: 192.168.0.9 node 2: 192.168.l.10

Step 1:

Test the connection and access from node 1 to Node 2:

[Root @ node1 ~] # Ssh root@192.168.0.10
The authenticity of host' 192. 168.0.10 (192.168.0.10) 'can't be established.
RSA key fingerprint is 6d: 8f: 63: 9b: 3b: 63: e1: 72: b3: 06: a4: e4: f4: 37: 21: 42.
Are you sure you want to continue connecting (yes/no )? Yes
Warning: Permanently added '192. 168.0.10 '(RSA) to the list of known hosts.
Root@192.168.0.10's password:
Last login: Thu Dec 10 22:04:55 2015 from 192.168.0.1
[Root @ node2 ~] #
Step 2:

Use the ssh-key-gen command to generate the public key and private key. Note that the private key can be encrypted to enhance security.

[Root @ node1 ~] # Ssh-keygen
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:
B4: 51: 7e: 1e: 52: 61: cd: fb: b2: 98: 4b: ad: a1: 8b: 31: 6d root@node1.ehowstuff.local
The key's randomart image is:
+ -- [RSA 2048] ---- +
|. ++ |
| O |
| O. |
|. O +... |
| S .. |
|... |
| O E oo. o |
| = Ooo. |
|. O. o. |
+ ----------------- +
Step 3:

Use the ssh-copy-id command to copy or upload the public key to the remote host, and append the id file to ~ of node 2 ~ /. Ssh/authorized_keys:

[Root @ node1 ~] # Ssh-copy-id-I ~ /. Ssh/id_rsa.pub 192.168.0.10
Root@192.168.0.10's password:
Now try logging into the machine, with "ssh '192. 168.0.10 '", and check in:
. Ssh/authorized_keys
To make sure we haven't added extra keys that you weren't expecting.
Step 4:

Verify password-free SSH logon node 2:

[Root @ node1 ~] # Ssh root@192.168.0.10
Last login: Sun Dec 13 14:03:20 2015 from www. ehowstuff. local

Have you found that configuring ssh password-free logon is very simple? Now we have finished setting up SSH password-free logon on CentOS/RHEL. I hope it will be helpful to you.

Related Article

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.