Windows系统下OpenSSH客户端无法自动加载密钥的问题求助
Windows系统下OpenSSH客户端无法自动加载密钥的问题求助
嗨,我最近遇到了个OpenSSH客户端的小问题,折腾了一阵没搞定,想请教下大家的思路:
我用的是Windows 10系统,自带的OpenSSH客户端,要连接一台Debian服务器,所有密钥都存在C:\Users\entityinarray\.ssh\目录里。
直接用命令连接的时候会报错:
PS C:\Users\entityinarray> ssh root@192.168.1.100 root@192.168.1.100: Permission denied (publickey).
但如果手动指定密钥文件,就能顺利连接上:
PS C:\Users\entityinarray> ssh root@192.168.1.100 -o IdentityFile=~\.ssh\id_okcomputer Enter passphrase for key 'C:\Users\entityinarray/\.ssh\id_okcomputer': Linux okserver 6.1.0-17-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.69-1 (2023-12-30) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Wed Feb 7 09:55:39 2024 from 192.168.1.2 root@okserver:~#
现在我想不用每次手动加-o IdentityFile参数,让OpenSSH自动找到这个id_okcomputer密钥。我已经在~/.ssh/config里配置了几个主机,但好像对这台192.168.1.100的服务器没起作用,我的config内容是这样的:
Host example.com HostName example.com Port 22 IdentityFile ~/.ssh/id_okcomputer Host radio.example.com HostName radio.example.com Port 2022 IdentityFile ~/.ssh/id_okcomputer Host linux-gaming HostName 123.123.123.123 Port 22 IdentityFile ~/.ssh/id_okcomputer
我自己琢磨了几个可能的方向,但不确定是不是全部:
- 是不是因为我的config里没有对应192.168.1.100的Host配置?如果给这台服务器加个Host条目,是不是就能自动加载密钥了?
- OpenSSH是不是只会自动识别标准命名的密钥(比如
id_rsa、id_ed25519这类),自定义名字的密钥必须手动指定或者加到ssh-agent里? - 有没有可能是我Windows下的
.ssh目录或者config文件权限不对,导致OpenSSH没读取这个配置?
有没有朋友遇到过类似的问题,或者能给我点排查建议呀?
备注:内容来源于stack exchange,提问作者EntityinArray
相关产品推荐
相关产品推荐

