Use the key to log in to the Linux server

I used Xshell to generate the key and upload it to the Linux server.

 

Go to the tool tab bar and select [New User Key Generation Wizard]

 

 

 

Set the password for the key

 

 Finally, just save it as a file.

==========================================

Create a new .ssh folder in the user's home directory

[root @ localhost ~] # mkdir . SSH   # New .ssh folder 
[root @ localhost ~] # chmod  700 . SSH /   # only read and write access to their 
[root @ localhost ~] # cd. SSH   # into the .ssh folder

I used Xftp that comes with Xshell to upload the public key to the .ssh folder.

$ cat id_dsa_1024.pub > authorized_keys
$ chmod 600 authorized_keys

Modify sshd.config

[root@localhost .ssh]# vim /etc/ssh/sshd_config
修改如下
PasswordAuthentication no
PubkeyAuthentication yes
AuthorizedKeysFile  .ssh/authorized_keys

Restart sshd

[root@localhost .ssh]# systemctl restart sshd

 

When using Xshell again, the name of the public key is displayed directly. You also need to enter the password set for the public key.

 

Guess you like

Origin www.cnblogs.com/panxk/p/12748700.html