Xshell Configuring SSH Password-free login-key public key and private key login

Source: Internet
Author: User

SSH login provides two kinds of authentication methods: password (password) authentication method and key authentication method. where password (password) authentication method is one of our most commonly used, here is the key authentication method to log on to linux/Unix.

Using key login is divided into 3 steps:
1. Generate key (public key and private key);
2. Place the public key into the server ~/.ssh/authorized_key file;
3. Configure the SSH client to log in using the key.

First, generate the key public key and private key (private key)

Open Xshell, click "Tools" in the menu bar and select "User Key Generation Wizard ..." In the popup menu, such as:

Pop up the "User Key Generation Wizard" dialog box, select "RSA" Public key encryption algorithm in the "Key Type" key, "Key Length" is selected as "2048" bit key lengths, such as:

Click "Next" and wait for key generation:

Proceed to the next step, enter the file name of key in "Key name", I Am "key" here, enter a password in "Passphrase" to encrypt the private key, and enter the password confirmation again, such as:

Click "Next", the key generation is complete (Public key format Select SSH2-OPENSSH format), here is the key, we can copy the public key and then save, you can also directly save the public key to the file, such as. The private key is not shown here and can be exported to a file in "User Key mangager ...":

Click the "Save as File ..." button to save the public key to the disk, with the file name "Key.pub" and alternate.

Second, upload public key to the server:

Log on to the server with Xshell, go to the "/root/.ssh/" directory, run the RZ command (if you do not have the RZ command, run the yum install Lrzsz installation), send the key.pub to the server, and then run the following command to set the public key ( Public Key) into the "Authorized_keys" file:

    1. [Email protected] ~]# cd/root/.ssh/
    2. [email protected]. ssh]# RZ
    3. RZ waiting to receive.
    4. [email protected]. ssh]# Cat me.pub >> Authorized_keys
    5. [email protected]. ssh]# chmod Authorized_keys
    6. [email protected]. ssh]# ls
    7. Authorized_keys known_hosts me.pub
    8. [email protected]. ssh]# Cat Authorized_keys
    9. Ssh-rsa aaaab3nzac1yc2eaaaabiwaaaqea4vcowfrarc1m3mfeal50v2z2siavo3ijpr/lz00ezah8ejfzhqjac/ Agkljyxmngpvdprdtlyco8h3p5vegxoegkcx74fdym0vndvabvd1xsd8elnyltccnk7rzjbi3htjox3q1n0vnmmb5d20d9occkax4ac94rwns33ec5cszntmg ain+uzl0flqkls1osywfahstwya6b33qg7y5e4b6j/caobnpx6egtbrgi97gxjhzwyylgrpwmuuhpqs5xtorb08cvxayzewtq1mxv0p+ Po4l1pbhlrf+tsoz5rsbzzjy4/jmazdxhntnayo0j0vngbbxkucnsahz

Third, configure Xshell to log on to the server using the key authentication method:

Open Xshell, click the "New" button, pop up the "New Session Properties" dialog box, in the "Connection" column, enter the IP address and port that you just configured the public key, as shown in:

Click on the Left "authentication", switch to the authentication section, in the "Method" select "Public Key" authentication, the user name input "root" (the public key is placed in the root directory in the. ssh folder), in "User Key" Select the private key that we just generated, "key", and "Passphrase", enter the encryption password for the private key.

Click OK, xshell configure SSH password-free login configuration complete.

Appendix: Linux Ssh-keygen command generates key:

In fact, under Linux Ssh-keygen can also generate a key, under Linux input ssh-keygen-t RSA, at the prompt, enter the name of the key (here is key) and the private key encryption password, both complete the key generation. Of the two files generated, "Key" is the private key, "Key.pub" is the public key. As shown in the following:

Xshell Configuring SSH Password-free login-key public key and private key 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.