1. Generate key
>SSH-KEYGEN-T RSA
Generating public/private RSA key pair.
Enter file in which to save the key (/HOME/USERNAME/.SSH/ID_RSA):
Enter passphrase (empty for no passphrase):
Enter same Passphrase again:
Your identification has been saved In/home/username/.ssh/id_rsa.
Your public key has been saved in/home/username/.ssh/id_rsa.pub.
The key fingerprint is:
73:37:d0:8b:0f:9d:31:56:84:1d:fe:1e:bc:c1:5d:f2 Username@mdt-9323e858fb8
Input ssh-keygen-t RSA represents the generation of RSA passwords that can be stored in a location, if you do not enter a location, use the default value, under the home under the name of the user. SSH, the middle appears to require a password, you can enter, or do not enter, if you want to remember the password
This generates two files Id_rsa and id_rsa.pub under/home/username/.ssh/, where Id_rsa is the private key, the id_rsa.pub is the public key, the private key is used by the client, and the public key is id_rsa.pub as Authorized_ Keys
2, modify the OpenSSH server-side configuration
Locate the file Sshd_config in the ETC directory at the installation location, such as my file location in/etc/sshd_config, modify the following two items
Authorizedkeysfile. Ssh/authorized_keys
Passwordauthentication No
The first parameter is used to describe the location of the public key file, the second is to force key access, not the username and password, and of course the second parameter can remain yes, which can be accessed in two ways.
3, restart Openss
net stop opensshd
net start opensshd