SSH Password-free login

Source: Internet
Author: User

SSH does not have password logon to use the public key and private key. Linux can be used to generate a ssh-keygen public/private key pair, below I take centos for example.

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

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


-p means the password,-p ' means null password, also can not use the-p parameter, this will be three car return, with-P on a return.
It generates an. SSH directory under/HOME/CHENLB,. SSH has Id_rsa and id_rsa.pub.

2. Copy the id_rsa.pub under a machine to B machine, in the B-machine. ssh/authorized_keys file, I use SCP to copy. [Chenlb@a ~]$ SCP. Ssh/id_rsa.pub chenlb@192.168.1.181:/home/chenlb/id_rsa.pub
chenlb@192.168.1.181 ' s Password:
Id_rsa.pub 100% 223 0.2kb/s 00:00


Because there is no password-free login, you need to enter a password.

The 3.B machine adds the id_rsa.pub copied from the a machine to the. ssh/authorzied_keys file. [Chenlb@b ~]$ cat id_rsa.pub >> Ssh/authorized_keys
[Chenlb@b ~]$ chmod Ssh/authorized_keys


Authorized_keys's permission is 600.

4.A Machine login B machine. [Chenlb@a ~]$ 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.
Are you sure your want to continue connecting (yes/no)? Yes
warning:permanently added ' 192.168.1.181 ' (RSA) to the list of known hosts.
Last Login:thu June 3 09:53:18 2008 from CHENLB
[Chenlb@b ~]$


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

Now a machine can log on to the B machine without a password.

Summary: The login can have a private key, the machine is logged in to have the public key of the machine. This public/private key pair is typically generated in the private key host host. The above is the RSA algorithm with the public/private key pair, of course, can also use DSA (corresponding file is id_dsa,id_dsa.pub)

want to let a,b machine without password to log on, that B machine in the same way as the above configuration can be.

Reference: Ssh-keygen usage  http://blog.163.com/chen98_2006@126/blog/static/158584272007101862513886/

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.