Use SSH public key to implement face password logon: RSA public key

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 public/private key pair with Ssh-keygen.
There is a machine a,b (192.168.0.32). Now want a password to login to B via SSH.


1. Generate a public/private key pair under a machine.

➜~ 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.
The command will generate a pair of key id_rsa and id_rsa.pub under the/root/.ssh directory.

RSA key for SSH in common use:
Id_rsa private Key
Id_rsa.pub Public Key
The following command produces different types of keys
Ssh-keygen-t DSA
SSH-KEYGEN-T RSA
Ssh-keygen-t RSA1

2. Copy all the files under the A-machine directory ~/.ssh/to the B-machine ~/.ssh/directory, first to create ~/.ssh on the B-machine directory, with the SCP replication.

[xqzhang@pekdev032 ~]$ mkdir. SSH

➜~ SCP. ssh/* 192.168.0.32:/home/xqzhang/.ssh/copy id_rsa.pub to Authorized_keys file,

[xqzhang@pekdev032 ~]$ chmod-SSH

[xqzhang@pekdev032. ssh]$ chmod 600 *

Because there is no password-free login, so you want to enter a B-machine root password.

Authorized_keys's permission, if!!!

. SSH directory permissions if the!!!


3.A Machine login B machine. Ssh-l Xqzhang 192.168.0.32

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

Now a machine can login without a password B machine.

Summary: Log on the machine 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)

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.