Set ssh Public/Private Key logon mode and ssh public/private login Mode
In Linux, ssh can be used to authenticate public and private keys when logging on to a remote host.
① Environment Description: two Linux Hosts, host1: 192.168.5.1, and host2: 192.168.5.10. Now set it on host1 and log on to host2 host.
② By default, the ssh service is automatically enabled. You can check netstat-nlutp | grepssh in Linux.
It is shown that port 22 of ssh has been listened on, so the ssh service has been enabled.
③ Generate a local key:
Ssh-keygen-t rsa is used to generate a key.
At this time, there will be a. ssh/id_rsa.pub public key file in the user's home directory, which needs to be sent to the authenticator. There are two methods
Method 1: scp ~ /. Ssh/id_rsa.pub root@192.168.5.10 :/~ // Enter the root user password of the other party.
Create a hidden. ssh folder and authorized_keys file under the root directory of 192.168.5.10, and append the copied file to the newly created authorized_keys. OK. After the append is complete, remotely log on to ssh-l username 192.168.5.1 on the client. For the first time, you need to enter the password and do not need password authentication when you log on again, because the re-Authentication uses the key authentication, you do not need to design the user authentication. Note: You need to change the permission for creating your own hidden files to 700 chmod 700 ~ /. Ssh
Method 2: ssh-copy-id-I ~ /. Ssh/id_rsa.pub root@192.168.5.1, do not need to manually create the file, the corresponding file content will be automatically appended.
Log on to ssh-l root192.168.5.1 and log on directly.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.