centos7.5 generate a public key, the key is to achieve free ssh landing

No password required to configure SSH 4-step
preparation work
to generate public and private key
import the public key to the certificate file, change the permissions
testing
1. Prepare the work
that this product sshd configuration file (requires root privileges)

Vi # / etc / SSH / sshd_config
1
find the following, and remove the comment symbol "#"

Yes RSAAuthentication
PubkeyAuthentication yes
AuthorizedKeysFile .ssh / authorized_keys
1
2
3
If you modify the configuration file, need to restart the sshd service (requires root privileges)

# /sbin/service sshd restart
1

  
2. Generate public and private
check whether they have been ssh key
# cd ~ / .ssh
1
if no key not have this folder, there is a backup and delete the original folder.

Generate a public key, private key
# SSH keygen -t-RSA
. 1
Press Enter 3, a blank password. The default generates two files in ~ / .ssh directory: id_rsa private key, id_rsa.pub public key. known_hosts file records the host list ssh key landing.


3. Import the public key to the certificate file, change the permissions
to copy SSH key to the target host, open SSH login without a password
# SSH-Copy-the above mentioned id the User @ Host
1
changes on the target host file permissions
# chmod 700 ~ / .ssh

# chmod 600 ~/.ssh/authorized_keys
1
2
3

4. Test
the local host ssh remote server

# Ssh -v root @ remote server IP
1

Original link: https: //blog.csdn.net/yjk13703623757/article/details/80449197

Guess you like

Origin www.cnblogs.com/soymilk2019/p/11210750.html