Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么每次ssh到服务器后还要输入密码才能添加密钥来授权密钥?_Ssh_Openssh - Fatal编程技术网

为什么每次ssh到服务器后还要输入密码才能添加密钥来授权密钥?

为什么每次ssh到服务器后还要输入密码才能添加密钥来授权密钥?,ssh,openssh,Ssh,Openssh,我跟着 但现在我还是每次都要输入密码 [root@web2 .ssh]# pwd /home/git/.ssh [root@web2 .ssh]# /etc/init.d/sshd restart Stopping sshd: [ OK ] Starting sshd: [ OK ] ------------

我跟着

但现在我还是每次都要输入密码

[root@web2 .ssh]# pwd
/home/git/.ssh

[root@web2 .ssh]# /etc/init.d/sshd restart
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]
------------

caojinhuamatoMacBook-Pro:.ssh caojinhua$ ssh -p 2332 git@xx.xx.xx.xxx
The authenticity of host '[xx.xx.xx.xxx]:2332 ([xx.xx.xx.xxx]:2332)' can't be established.
RSA key fingerprint is 9b:e6:97:b1:a7:22:bd:b3:20:57:f3:0b:01:4e:b7:eb.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[xx.xx.xx.xxx]:2332' (RSA) to the list of known hosts.
git@xx.xx.xx.xxx's password: 
Last login: Mon Jun 27 11:00:16 2011 from 121.x8.23x.1x3
[git@web2 ~]$ 

您应该确保
~/.ssh/authorized_keys
的权限为600。

您没有正确添加密钥,密钥格式错误,权限问题,或者主机上的ssh配置仅允许密码身份验证

在这四种可能性中,第二种可能性最大。例如,如果您将SSH.com格式的密钥剪切并粘贴到授权的密钥中,它将不起作用。您必须首先将其转换为OpenSSH格式


您的公钥在授权密钥中是什么样子的?(发布它没有坏处——毕竟它是一个公钥)

好的,看起来像是openssh密钥。下一步是尝试连接ssh-v,看看它说的问题是什么。您是否将您的公共ssh密钥放入了authorized_keys文件中?