Linux 如何在没有密码和公钥的情况下进行ssh登录?

Linux 如何在没有密码和公钥的情况下进行ssh登录?,linux,bash,ssh,Linux,Bash,Ssh,我知道如何通过将公钥复制到远程服务器来启用ssh登录而无需密码: cat.ssh/id_rsa.pub | sshb@B“cat>.ssh/authorized_keys” 是否可以在没有密码和公钥的情况下登录到远程服务器 事实上,现在我有两台服务器,A和B 在a中只有一个.ssh/id\u rsa,在B中没有.ssh/authorized\u keys,但我可以从a无密码登录到B 设置此项的人已退出,因此我不知道他是如何做到的。您的服务器可能配置了不同的密钥搜索路径 在/etc/ssh/ssh

我知道如何通过将公钥复制到远程服务器来启用ssh登录而无需密码:

cat.ssh/id_rsa.pub | sshb@B“cat>.ssh/authorized_keys”

是否可以在没有密码和公钥的情况下登录到远程服务器

事实上,现在我有两台服务器,
A
B

a
中只有一个
.ssh/id\u rsa
,在
B
中没有
.ssh/authorized\u keys
,但我可以从
a
无密码登录到
B


设置此项的人已退出,因此我不知道他是如何做到的。

您的服务器可能配置了不同的密钥搜索路径

/etc/ssh/sshd\u config
中找到该行:

AuthorizedKeysFile  .ssh/authorized_keys
如果更改了此项,服务器将在不同的文件中搜索密钥

编辑:还有一些方法可以通过公钥进行身份验证

许多以
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.

您可以尝试
ssh-v
来显示身份验证的详细过程。
debug1:尝试私钥:/***/.ssh/id\u rsa debug1:读取PEM私钥完成:键入rsa debug1:身份验证成功(公钥)。
您的服务器似乎正在正常进行公钥身份验证。请更改标题以与之匹配。从连接和服务器获取详细日志。它会回答你所有的问题。ssh服务器配置也会有帮助。我只发现:
HostDsaKey/etc/ssh/dsa_-keys
如果未设置该选项,则也接受
.ssh/authorized_-keys 2
。它是否存在?不,在
/etc/ssh/sshd\u config
文件中没有
AuthorizedKeysFile**
条目,也没有
.ssh/authorized\u keys2
文件请检查以authorized开头的其他行。