如何指定 OpenSSH 的 SSH 客户端(OpenSSH_7.5p1、OpenSSL 1.0.2k 2017 年 1 月 26 日;Git for Windows v2.11.1)向 SSH 兼容守护进程(例如 Apache Mina SSHD(Gerrit)提供公钥/私钥对的顺序)代码审查服务)。我的目的是在回退到 RSA 之前尝试使用 Ed25519 公钥/私钥对进行身份验证。
鉴于用户主目录下的以下标准 Ed25519 和 RSA 公钥/私钥对:
~/.ssh/id_ed25519{,.pub}~/.ssh/id_rsa{,.pub}以及用户 SSH 配置文件 (~/.ssh/config) 中的以下主机部分:
Host foobar foobar.example.com
Hostname foobar.example.com
IdentityFile ~/.ssh/id_ed25519
Host *
IdentityFile ~/.ssh/id_ed25519
IdentityFile ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)
在调试模式下测试 SSH 连接时:
$ ssh -Tv bob@foobar
debug1: Reading configuration data ~/.ssh/config
debug1: ~/.ssh/config line 49: Applying options for foobar
debug1: ~/.ssh/config line 63: Applying options for *
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: ~/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering ED25519 public key: ~/.ssh/id_ed25519
debug1: Server accepts key: pkalg ssh-ed25519 blen 51
debug1: Authentication succeeded (publickey).
Run Code Online (Sandbox Code Playgroud)
我可以看到 OpenSSH 的 SSH 客户端首先提供了 RSA 公钥/私钥对。但为什么不先 Ed25519 呢?
添加IdentitiesOnly选项。如果没有此选项,SSH 将首先尝试可用的默认 ssh 密钥:id_rsa, id_dsa, id_ecdsa. 要更改此行为,请将您的配置替换为:
Host foobar foobar.example.com
Hostname foobar.example.com
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
Host *
IdentityFile ~/.ssh/id_ed25519
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1284 次 |
| 最近记录: |