【发布时间】:2020-02-16 18:12:06
【问题描述】:
假设我添加了一个新的遥控器,我想通过 ssh 连接到该遥控器。我忘记将服务器的主机密钥添加到我的~/.ssh/known_hosts 文件并无论如何都要连接。令我惊讶的是,我收到以下警告
警告:将 IP 地址“xxxx:xxx:xxx:xxxx::xxx”的 RSA 主机密钥永久添加到已知主机列表中
我不希望 git 在这种情况下自动添加主机密钥。如果有人问我或者没有添加主机密钥,我会更高兴。
我尝试添加
[core]
sshCommand = ssh -o StrictHostKeyChecking=ask
致我的~/.gitconfig。我的~/.ssh/config 中也有StrictHostKeyChecking ask。这两个设置都被忽略。我的 git 版本是 2.17.1。
问题:
- 如何防止git自动添加主机密钥?
- 为什么我的 StrictHostKeyChecking 设置被忽略了?
【问题讨论】:
-
我无法通过 MacPorts 安装的 Git 2.25.0 复制此行为。我得到了正常的 ssh 询问行为。
git fetch originThe authenticity of host '...' can't be established. RSA key fingerprint is SHA256:blahblahblah. Are you sure you want to continue connecting (yes/no)? -
检查
git config -l --show-origin是否有什么奇怪的地方。 -
@Schwern
core.sshcommand=ssh -o StrictHostKeyChecking=ask出现在那里并且没有其他冲突的命令。我会检查更新版本的 git。 -
@Schwern 刚刚在 arch linux 上使用 git 版本 2.25.0 进行了测试。无法使用相同的 repo 重现错误。似乎它已更改/修复。
标签: git