Configure SSH password-free logon in Xshell

Source: Internet
Author: User

Configure SSH password-free logon in Xshell

When purchasing a server, password authentication is always used. Although there has been no problem, I always feel that this login method is not correct. Because the company generally uses the key authentication login method. So today, I switched my server login Method to the key login method. There is no difficulty in the whole process. This article is mainly recorded.

Perform the following three steps:

1. Generate a key

2. Place keys and configure ssh

3. Configure the ssh client to log on with a key

1. Generate a key

1. Use Xshell to generate a key

You can use any of the above methods to generate a key;

Save the generated key as a file.

Save as id_rsa.pub (Public Key)

2. Use git to generate a key

Run the ssh-keygen-t-rsa command.

2. Place the public key on the server and set ssh

Log on to the server using Xshell and go to the "/root/. ssh/" directory.

Send id_rsa.pub to the server and run the following command to import the Public Key to the "authorized_keys" file:

[Root @ bkjia ~] # Cd/root/. ssh/

[Root @ bkjia. ssh] # cat id_rsa.pub> authorized_keys

[Root @ bkjia. ssh] # chmod 600 authorized_keys

[Root @ bkjia. ssh] # chown bkjia: yearnfar authorized_keys # Change User and user group to your own

Verify that the logon is correct. Change the logon mode from password to publickey on the ssh client. Use the generated public key file.

If logon fails, check whether PubkeyAuthentication In the ssh configuration file (/etc/ssh/sshd_config) is yes.

If the verification is successful, you can disable Password Logon. edit/etc/ssh/sshd_config, change PasswordAuthentication to no, and change ChallengeResponseAuthentication to no.

Restart sshd (service sshd restart)

PS:

1. Make sure that the directory. ssh belongs to the current user and the permission is 700.

2. Make sure that the file authorized_keys belongs to the current user and the permission is 600.

The/home/user directory must also be 700 !!! If you use root to change its permissions, the logon fails.

3. Set ssh client login

4. Security suggestions

Log On with key authentication. Do not set root Key Authentication. You can use su or sudo to obtain super administrator permissions.

Xshell uploads files to Linux Hosts in Windows

Troubleshooting of Chinese garbled characters when Xshell logs on to CentOS 6.3

VirtualBox4.12 text installation CentOS 5.4 and Xshell connection tutorial PDF

Xshell connects to CentOS6.5 iptables or ls to output garbled characters

Use Xshell to log on to VMware Linux

Use the Xshell key authentication mechanism to remotely log on to Linux

This article permanently updates the link address:

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.