我在Ubuntu服务器上。 我正在尝试启用SSH隧道,以便在我的项目中添加git remote。
authorized_keys文件中 当我尝试打开一个远程shell我得到错误Server refused our key 。
检查日志: Connection closed by <ip> [preauth] /var/log/auth.log Connection closed by <ip> [preauth] 。
更多信息:
~/.ssh/authorized-keys有权限664。
该文件被命名为authorized-keys not authorized_keys这可能是一个问题?
我错过了什么?
名称应该是~/.ssh/authorized_keys而不是authorized-keys 。 可能有人设置这个(为另一个键)命名文件错误,同样想知道为什么它不起作用。
此外,该文件不应该由任何人,而是所有者可写。 因此,权限应该是644。 你可以修复使用
chmod go-w ~/.ssh/authorized_keys
这个答案可能有点晚,但对于那些寻求类似问题的人,我build议最好的办法是copy public key copy到远程服务器的authorized_key文件中,使用以下命令:
ssh-copy-id remoteuser@remotehost
这会将当前用户的pub密钥复制到远程服务器,并避免input错误。
此外,可以使用-i标志指向不同的标识文件。