Ama*_*rus 46 ssh private-key public-key
像大多数系统管理员一样,我一直使用 openssh。我有大约一打 ssh 密钥,我喜欢为每个主机使用不同的 ssh 密钥。但是,当我第一次连接到主机时,这会导致问题,而我只有密码。我只想使用密码连接到主机,在这种情况下没有 ssh 密钥。但是 ssh 客户端将提供我的所有公钥~/.ssh/
(我通过查看 的输出知道这一点ssh -v
)。由于我有这么多,我会因为太多的身份验证失败而断开连接。
有没有办法告诉我的 ssh 客户端不要提供所有的 ssh 密钥?
And*_*ier 47
尽管其他人已经通过基于配置的解决方案暗示了这一点,但可能值得指出的是,您可以在命令行上轻松地一次性完成此操作:
ssh -o 'PubkeyAuthentication no' myhostname.mydomain
Run Code Online (Sandbox Code Playgroud)
Mat*_*ens 46
根据以下手册页,这是预期的行为ssh_config
:
IdentityFile
Specifies a file from which the user's DSA, ECDSA or DSA authentica?
tion identity is read. The default is ~/.ssh/identity for protocol
version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and ~/.ssh/id_rsa for
protocol version 2. Additionally, any identities represented by the
authentication agent will be used for authentication.
[...]
It is possible to have multiple identity files specified in configu?
ration files; all these identities will be tried in sequence. Mul?
tiple IdentityFile directives will add to the list of identities
tried (this behaviour differs from that of other configuration
directives).
Run Code Online (Sandbox Code Playgroud)
基本上,指定IdentityFile
s 只是将密钥添加到 SSH 代理已经提供给客户端的当前列表中。
尝试在.ssh/config
文件底部使用以下内容覆盖此行为:
Host *
IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)
您还可以在主机级别覆盖此设置,例如:
Host foo
User bar
IdentityFile /path/to/key
IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)
小智 12
按照 James Sneeringer 的解决方案,您可能只想按照以下方式设置 ssh_config:
Host *.mycompany.com
IdentityFile .ssh/id_dsa_mycompany_main
Host *.mycustomer.com
IdentityFile .ssh/id_dsa_mycustomer
Host *
RSAAuthentication no #this should be up top, avoid ssh1 at all costs
PubkeyAuthentication no
Run Code Online (Sandbox Code Playgroud)
如果您使用特定密钥连接到不在公共域中的多台机器,请考虑在您自己的 DNS 中为它们提供所有 CNAME。我对所有客户系统都这样做。
归档时间: |
|
查看次数: |
20261 次 |
最近记录: |