Xshellssh password-free logon-Publickey and private key Logon

Source: Internet
Author: User
Ssh logon provides two authentication methods: password authentication and key authentication. Password Authentication is one of the most common methods. Here we will introduce how to log on to linuxunix using the key authentication method.

Ssh logon provides two authentication methods: password authentication and key authentication. Password (password) authentication is one of the most common methods. Here we will introduce the key authentication method for logging on to linux/unix.

You can log on with the accesskey in three steps:
1. Generate a key (Public Key and private key );
2. Place the Public Key on the server ~ /. Ssh/authorized_key file;
3. Configure the ssh client to log on with the key.

1. Generate the Public key and Private Key)

Open Xshell, click "tools" in the menu bar, and select "User Key Generation Wizard..." in the pop-up menu, for example:

The "User Key Generation Wizard" dialog box is displayed. In the "Key Type" option, select the "RSA" public Key encryption algorithm, and the "Key Length" is set to "2048" Key Length, for example:

Click "Next" and wait for the key to be generated:

Next, enter the Name of the Key file in "Key Name". Here, it is "key". In "Passphrase", enter a password to encrypt the private Key, enter the password again for confirmation, such:

Click "Next", the key is generated (Public key Format select SSH2-OpenSSH Format), this shows the Public key, we can copy the Public key and then save, you can also directly Save the Public key to the file, for example. The private Key is not displayed here. You can export it to a file in "User Key Mangager:

Click the Save as file... button to Save the Public key to the disk. The file name is "key. pub.

2. Upload the Public Key to the server:

Log on to the server using Xshell, go to the "/root/. ssh/" directory, and run rzCommand(If there is no rzCommandRun yum install lrzsz), send key. pub to the server, and then run the following command to import the Public Key to the "authorized_keys" file:

  1. [Root @ localhost ~] # Cd/root/. ssh/
  2. [Root @ localhost. ssh] # rz
  3. Rz waiting to receive.
  4. [Root @ localhost. ssh] # cat me. pub> authorized_keys
  5. [Root @ localhost. ssh] # chmod 600 authorized_keys
  6. [Root @ localhost. ssh] # ls
  7. Authorized_keys known_hosts me. pub
  8. [Root @ localhost. ssh] # cat authorized_keys
  9. Ssh-rsa Secure/LZ00EZah8EjfZhqjAc/secure + secure/secure + Po4L1pbHLRf + TSoZ5RSBZZjY4/JMAzdXHNtnAyO0j0VNGbBXKUcNSAHZ

3. Configure Xshell to log on to the server using key authentication:

Open Xshell and click "New". The "New Session Properties" dialog box is displayed. In the "Connection" column, enter the IP address and port of the Public Key you Just configured, as shown in:

Click "Authentication" on the left to switch to the Authentication topic. Select "Public Key" for "Method" and enter "root" as the user name (the Public Key is stored in the root directory. in the ssh folder), select the generated private Key "key" in "User Key", and enter the encryption password of the private key in "Passphrase.

Click OK to complete ssh password-free logon configuration for Xshell.

Appendix: linux ssh-keygen command generation key:

In fact, ssh-keygen in linux can also generate a key, enter ssh-keygen-t rsa in linux, and enter the key name (key here) at the prompt) and the private key to encrypt the password. In the two files generated, "key" is the private key and "key. pub" is the public key. As shown in:

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.