There are multiple development public servers on an intranet, and each user has done password-free login to the corresponding server a and b, which has always been very easy to use, but suddenly it can't be used; the reason why the previous server was multi-user felt that it was too slow, so Changed a high-end server, and copied the original public key directly to the development effort, but it was all right. A few days ago, the little friend dealt with the server c password-free, and regenerated the public key, overwriting the original file. vim id_rsa.pub is copied to the server. As a result, the development ab server cannot be password-free, and the processing c server cannot log in without password; the development a and b servers are caused by the change of the public key, and the c server checks sshd_conf and authorized_keys In the future, there is a problem with the content posted on vim id_rsa.pub, so still scp id_rsa.pub root@B:~/id_rsa.pub, and then log in to the b server cat ~/id_rsa.pub >> ~/.ssh/authorized_keys This is safer .
There is a problem with password-free login: 1. sshd_conf configuration check;
2. id_rsa.pub changes;
3. View authorized_keys;
4. Permission issues: The authorized_keys file in the .ssh directory needs 600 or 644 permissions
5. Edit sudo vi /etc/ssh/sshd_config for StrictModes problem, find #StrictModes yes and change it to StrictModes no
Server A needs password-free access to Server B:
1. Generate the public key key on A and execute the command
ssh-keygen -t rsa 或者 ssh-keygen -t rsa -P ''
Just press Enter all the way, two files id_rsa and id_rsa.pub will be generated in the ~/.ssh directory, id_rsa is the private key, and id_rsa.pub is the public key
2. Copy the public key id_rsa.pub to the B machine
scp id_rsa.pub root@B:~/id_rsa.pub
3. Append id_rsa.pub to the ~/.ssh/authorized_keys file under the user root/.ssh corresponding to server B
cd /home/user/.ssh
cat id_rsa.pub >> authorized_keys Note that >> do not overwrite;
4. Set authorized_keys permission
chmod 600 ~/.ssh/authorized_keys