SSH Password-free login

Source: Internet
Author: User


SSH Password-free login


SSH login with no password to use the public and private keys. Linux can be used to generate a public/private key pair with Ssh-keygen, below I take CentOS as an example.

There is machine A (192.168.1.155), B (192.168.1.181). Now want to a through SSH password-free login to B.

1. Generate a public/private key pair under the a machine.
[[email protected] ~]$ ssh-keygen-t rsa-p '


-P for the password,-p ' means the empty password, you can not use the-p parameter, so that three cars to enter, with-P on a return.

It generates the. SSH directory under/HOME/CHENLB, with Id_rsa and id_rsa.pub under SSH.
The following command produces different types of keys
Ssh-keygen-t DSA
SSH-KEYGEN-T RSA
Ssh-keygen-t RSA1



2. Copy the id_rsa.pub under the A machine to the B machine, in the. ssh/authorized_keys file of the B machine, this is not a folder and is copied with SCP.
[Email protected] ~]$ SCP. Ssh/id_rsa.pub 192.168.1.181:/home/
[email protected] ' s password:
Id_rsa.pub 100% 223 0.2kb/s 00:00


Since there is no password-free login, enter the password.

The 3.B Machine writes the id_rsa.pub copied from a machine into the. ssh/authorzied_keys file.
[email protected] ~]$ cat id_rsa.pub >>. Ssh/authorized_keys
[Email protected] ~]$ chmod Ssh/authorized_keys


Authorized_keys's permission if 600.

4.A Machine login B machine.
[[email protected] ~]$ ssh 192.168.1.181
The authenticity of host ' 192.168.1.181 (192.168.1.181) ' can ' t be established.
RSA key fingerprint is 00:a6:a8:87:eb:c7:40:10:39:cc:a0:eb:50:d9:6a:5b.
Is you sure want to continue connecting (yes/no)? Yes
warning:permanently added ' 192.168.1.181 ' (RSA) to the list of known hosts.
Last Login:thu Jul 3 09:53:18 from CHENLB
[Email protected] ~]$


The first time you log in is when you want to enter Yes.

Now a machine can be no password login B machine.

Summary: Log on the machine can have a private key, the machine to be logged on to have the public key of the machine. This public/private key pair is typically generated on the private key host. Above is the RSA algorithm's public/private key pair, of course, you can also use DSA (the corresponding file is id_dsa,id_dsa.pub)

Want to let A, B machine without password mutual login, that machine is configured in the same manner as above.


SSH Password-free login

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.