天天看点

.ssh 密钥有,密钥文件又有,无法实现免密钥登录

问题现象密码输入正确无法发送过去密钥

[root@localhost .ssh]# ssh-copy-id -i id_rsa.pub " -p 22 [email protected]"

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "id_rsa.pub"

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

 -p 22 [email protected]'s password:

Permission denied, please try again.

Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

着一切的祸根都是.ssh的权限问题

[root@localhost .ssh]# ssh-copy-id -i id_rsa.pub "[email protected]"       

[email protected]'s password:

sh: .ssh/authorized_keys: 权限不够

随后把.ssh的权限改为700就好了

chmod 700 .ssh

[root@localhost .ssh]# ssh-copy-id -i id_rsa.pub "[email protected]"

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '[email protected]'"

and check to make sure that only the key(s) you wanted were added.

继续阅读