Use a plaintext ssh password to log on to a remote server on a linux Desktop
1. The safest way to log on to a remote server in linux is password-free login. 2. Principle
Implemented through public key encryption and Private Key decryption.
The User Machine sub-stores the private key and the remote machine sub-stores the corresponding public key.
The remote host uses the public key to encrypt a piece of text for the user.
The user's machine uses the private key to decrypt and obtain the "text", which is then sent to the remote machine in plaintext format.
If the text information received by the remote host is consistent with the text information, the user is trusted, that is, the user is a real user.
Implementation 1
First, log on to the remote host through ssh, and name it DEV. (Ssh yansong @ dev, and then enter the password to log on)
Cd ~ & Cd. ssh // enter the personal environment and try to enter the. ssh directory
If the. ssh directory does not exist, create it (mkdir. ssh)
Ls // check whether the id_rsa and id_rsa.pub files exist in the. ssh directory.
If the preceding two files do not exist, create them (enter ssh-keygen-t rsa, press enter, and press Enter)
Cat id_rsa.pub> authorized_keys // copy the public key to the location where the verification key file is stored.
Chmod 600 authoried_keys // rw ---
Scp yansong @ dev:. ssh/id_rsa *~ //. Ssh // copy id_rsa and id_rsa.pub to the corresponding ~ /. Ssh directory
Implementation 2
Use the plaintext password.
Install sshpass first
Sudo apt-get install sshpass
Then use
Sshpass-p 'Password' ssh remote machine username @ remote machine ip-C