visual-studio-code - WSL2 密码提示中 VS Code 上的远程 SSH

标签 visual-studio-code ssh

我正在尝试在 Ubuntu WSL2 的 VS Code 中通过 SSH 连接到我的服务器。但是,每当我建立连接时,它都使用 Windows SSH 而不是我的 Ubuntu WSL2。有没有办法在 Ubuntu 中启动远程 SSH 终端而不是默认的 Windows 命令提示符?

[10:14:37.201] Log Level: 2  
[10:14:37.205] <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7d0f1810120918500e0e153d4d534b4f534d" rel="noreferrer noopener nofollow">[email protected]</a>  
[10:14:37.205] win32 x64  
[10:14:37.208] "remote.SSH.sshPath": /usr/bin/ssh  
[10:14:37.208] "remote.SSH.sshConfigurationFile": ~/.ssh/config  
[10:14:37.245] Checking ssh with "/usr/bin/ssh -V"
[10:14:37.251] Got error from ssh: spawn /usr/bin/ssh ENOENT  
[10:14:37.251] The specified path /usr/bin/ssh is not a valid SSH binary  
[10:14:37.252] Checking ssh with "ssh -V"  
[10:14:37.296] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5  
[10:14:37.300] Using SSH config file "~/.ssh/config"
[10:14:37.300] Running script with connection command: ssh -T -D 60054 -F "~/.ssh/config" "test-wsl" bash  
[10:14:37.303] Terminal shell path: C:\WINDOWS\System32\cmd.exe

最佳答案

如果其他人遇到了与我相同的问题,似乎 VS Code 中的远程服务器正在将 cmd 作为默认终端,因此我必须将我的私钥复制到 /mnt/c/Users/{user}/.ssh 目录,以便使基于 ssh key 的身份验证正常工作。如果我可以将默认 shell 更改为 C:\WINDOWS\System32\bash.exe,那就更好了。

关于visual-studio-code - WSL2 密码提示中 VS Code 上的远程 SSH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65271806/

相关文章:

visual-studio-code - 如何在 Ubuntu 主机上终止 VSCode 远程服务

Git 设置 ssh key

linux - 无法通过 ubuntu 中的配置文件将 ssh 连接到 ec2。权限被拒绝(publickey、gssapi-keyex、gssapi-with-mic)

arrays - 如何在远程 ssh bash 命令中迭代本地数组

visual-studio-code - VSCode - 禁用 "Could not find a declaration file for module"的三个点

visual-studio-code - 有没有办法使用 VS Code 任务运行命令?

azure - ACS 中 Mesosphere 的 SSH 转发失败并显示 "administratively prohibited"

ssh - 设置从 Linux 到 Windows 10 的无密码 SSH

reactjs - 如何使用 VSCode 在 Firefox 中保留扩展并请求启动

ruby-on-rails - 带有 VSCODE 的 rdebug-ide 返回 cannot load such file --/app/app/rails 错误