1. Preface
This article briefly introduces how to use SSH for password-free login. All the operations are completed in UNIX.
2. Principles
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.
3. Specific operations
- 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
4. Post
The above content may be inappropriate. If not, please correct me.
5. Reference
SSH Login Without Password