1. Generate a 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
Enter ssh-keygen-t rsa to generate the RSA password, which can be stored. If you do not enter the location, use the default value, which is under the current user name in the home. in SSH, a password is required in the middle. You can enter or not enter the password. If you enter the password, remember the password.
In this way, in/home/username /. two files, id_rsa and id_rsa.pub, are generated under ssh/. id_rsa is the private key, id_rsa.pub is the public key, and the private key is used by the client. The name of id_rsa.pub is authorized_keys.
2. Modify the OpenSSH server configuration
Find the sshd_config file in the etc directory of the installation location. For example, if my file is located in/etc/sshd_config, modify the following two items:
Authorizedkeysfile. Ssh/authorized_keys Key Authentication
Passwordauthentication No Password Authentication
The first parameter is used to describe the location of the public key file, and the second parameter is forced to use the key for access, instead of the user name and password. Of course, the second parameter can be set to yes, so there are two access methods.
3. Restart openss
Net stop opensshd
Net start opensshd
4. Restart sshd
Service sshd restart
This article from the "good memory as bad pen" blog, please be sure to keep this source http://10808387.blog.51cto.com/2925559/1565192
SSH key Creation