我知道如何通过将公钥复制到远程服务器来启用没有密码的ssh登录:
cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
是否可以在没有密码和公钥的情况下登录远程服务器?
事实上,现在我有两台服务器,A
和B
.ssh/id_rsa
中只有A
,.ssh/authorized_keys
中没有B
,但我可以从B
登录A
没有密码。
设置此功能的人已退出,所以我不知道他是怎么做到的。
答案 0 :(得分:1)
您的服务器可能配置了不同的密钥搜索路径。
在/etc/ssh/sshd_config
中找到该行:
AuthorizedKeysFile .ssh/authorized_keys
如果更改了此项,服务器将搜索不同的文件以获取密钥。
编辑:还有一些方法可以通过publickey进行身份验证。
许多以Authorized
开头的配置选项都有效。
从手册:
AuthorizedKeysCommand
Specifies a program to be used to look up the user's public keys.
The program must be owned by root, not writable by group or oth‐
ers and specified by an absolute path. Arguments to
AuthorizedKeysCommand accept the tokens described in the TOKENS
section. If no arguments are specified then the username of the
target user is used.
The program should produce on standard output zero or more lines
of authorized_keys output (see AUTHORIZED_KEYS in sshd(8)). If a
key supplied by AuthorizedKeysCommand does not successfully
authenticate and authorize the user then public key authentica‐
tion continues using the usual AuthorizedKeysFile files. By
default, no AuthorizedKeysCommand is run.