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

ssh 密钥生成

ssh-keygen

一路回撤

 

 

 

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

[root@localhost .ssh]# ssh-copy-id -i id_rsa.pub " -p 22 test@10.10.202.190"
/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 test@10.10.202.190's password:
Permission denied, please try again.
 -p 22 test@10.10.202.190's password:
Permission denied, please try again.
 -p 22 test@10.10.202.190's password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

 

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

[root@localhost .ssh]# ssh-copy-id -i id_rsa.pub "test@10.10.202.190"       
/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
test@10.10.202.190's password:
sh: .ssh/authorized_keys: 权限不够

 

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

chmod 700 .ssh

 

[root@localhost .ssh]# ssh-copy-id -i id_rsa.pub "test@10.10.202.190"
/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
test@10.10.202.190's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'test@10.10.202.190'"
and check to make sure that only the key(s) you wanted were added.

 

 

chmod 600 .ssh/authorized_keys

posted @ 2022-07-19 11:08  苦读二十年  阅读(1354)  评论(0编辑  收藏  举报