当我离开桌面时,我在笔记本电脑上使用带有 Ubuntu 的 WSL 在 Linux 上进行开发(使用本机 Linux,我不会遇到任何此类问题)。我有私人 git 存储库设置,我使用 ssh 连接到它。我配置了 ssh(在 中.ssh/config
),并且我的 VPS、GitHub、其他 VPS 用户帐户等有多个密钥,因此我ssh-add
在桌面上使用它们来管理它们。但在我的笔记本电脑上,在 WSL 中,当我尝试连接到我的 VPS 时,ssh 会要求输入密钥的密码。当我尝试这样做时,ssh-add .ssh/mykey
出现错误:
$ ssh-add .ssh/mykey
Could not open a connection to your authentication agent.
Run Code Online (Sandbox Code Playgroud)
但ssh-agent
正在运行:
$ ps -e | grep ssh
4455 ? 00:00:00 ssh-agent
5517 ? 00:00:00 sshd
6164 pts/0 00:00:00 ssh
Run Code Online (Sandbox Code Playgroud)
我不明白为什么会有问题。如果我杀死当前正在运行的ssh-agent
并再次启动它(使用eval $(ssh-agent -s)
)它工作正常。