Logging in with SSH KEY can increase the security of the system and prevent the server from being compromised due to the password being cracked.
carried out
ssh-keygen -t rsa
At this time, two files are generated in the /root/.ssh/ directory, id_rsa is the private key, and id_rsa.pub is the public key. The private key is downloaded to the local computer and stored properly (you can't log in again after losing the server). For security, it is recommended to delete the private key on the server side. The public key can be disclosed at will.
Import the public key to VPS using the following command
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
carried out
vi /etc/ssh/sshd_config
Modify the configuration file, remove the "#" sign and press esc to enter wq to save.
Perform
service sshd restart
Restart the ssh service
SSH KEY login configuration is complete
Use the generated key file (id_rsa) to log in on the client
Linux configuration disable root password remote login
carried out
vim /etc/ssh/sshd_config
Change the yes in the red box below to no
Restart
service sshd restart