2019-01-20 解决SSH设置免密登录,却老是要求Enter passphrase for key '/root/.ssh/id_rsa':

SSH怎么生成公钥私钥免密登录什么的就不细说了,今天记录的是怎么解决设置完之后,每次还提示”Enter passphrase for key '/root/.ssh/id_rsa':“ 或者其他用户名的这个坑。
ssh localhost, 是不是要你输入id_rsa的密码?
那么一步步检查,到~/.ssh目录下,检查文件和文件权限是否都正确:
.ssh 700
id_rsa 600
id_rsa.pub 644
authorized_keys 600 已经有你的public key
接下来要做的是:

axing@LD8:~/.ssh$ ssh-add id_rsa
Could not open a connection to your authentication agent.

这说明agent设置有问题,我们接着看

axing@Bastion_LD8:~/.ssh$  ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-w0wtXVdGAZet/agent.21338; export SSH_AUTH_SOCK;
SSH_AGENT_PID=21339; export SSH_AGENT_PID;
echo Agent pid 21339;

接着执行以下命令

axing@LD8:~/.ssh$ eval $(ssh-agent)
Agent pid 21341
#再添加私钥到agent
axing@LD8:~/.ssh$ ssh-add id_rsa
Enter passphrase for id_rsa:
Identity added: id_rsa (id_rsa)
#测试一下:
axing@LD8:~/.ssh$ ssh localhost
Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-43-generic x86_64)
...

你可能感兴趣的:(2019-01-20 解决SSH设置免密登录,却老是要求Enter passphrase for key '/root/.ssh/id_rsa':)