Visual Studio Code 远程 SSH 在 ssh_config 中使用 Windows 用户名而不是用户名

Mil*_*los 11 windows-7 visual-studio-code vscode-remote

我在 Windows 7 上使用 Visual Studio Code,以及 Microsoft 的远程 SSH 扩展。我添加了新的远程主机,并将配置保存在 ssh_config 文件中。

当我打开该文件,一切正常,这两个UserHost值。但是,当扩展要求我输入密码时,我可以看到它没有使用 myuser@myremotehost.com ,这些值写在 ssh_config 文件中,而是使用正确的主机,但它也使用我的 Windows 用户名而不是我的用户名在 ssh_config 文件中设置。

有什么解决办法吗?

小智 16

我发现在 .ssh 配置文件的主机定义中包含用户名为我修复了它。

从以下位置编辑 C:/Users/me/.ssh/config 的内容:

Host bar
  User foo
  HostName bar
  ForwardAgent yes
Run Code Online (Sandbox Code Playgroud)

到:

Host foo@bar
  User foo
  HostName bar
  ForwardAgent yes
Run Code Online (Sandbox Code Playgroud)