简体   繁体   English

通过 WSL 使用 VSCode 连接到远程 linux 服务器 - 文件位置问题?

[英]Connecting to remote linux server with VSCode through WSL - File location issue?

When attempting to use VS Code / WSL to remote into a linux server hosted as a Digital Ocean droplet, we're getting this error:当尝试使用 VS Code / WSL 远程访问作为 Digital Ocean 液滴托管的 linux 服务器时,我们收到此错误:

[17:38:24.258] Log Level: 2
[17:38:24.260] remote-ssh@0.63.0
[17:38:24.260] win32 x64
[17:38:24.262] SSH Resolver called for "ssh-remote+100.100.10.100", attempt 1
[17:38:24.263] "remote.SSH.useLocalServer": false
[17:38:24.263] "remote.SSH.showLoginTerminal": false
[17:38:24.263] "remote.SSH.remotePlatform": {"$remote_server_name":"linux"}
[17:38:24.264] "remote.SSH.sshPath": undefined
[17:38:24.264] "remote.SSH.sshConfigurationFile": undefined
[17:38:24.264] "remote.SSH.useFlock": true
[17:38:24.265] "remote.SSH.lockfilesInTmp": false
[17:38:24.265] "remote.SSH.localServerDownload": auto
[17:38:24.265] "remote.SSH.remoteServerListenOnSocket": false
[17:38:24.265] "remote.SSH.showLoginTerminal": false
[17:38:24.266] SSH Resolver called for host: 100.100.10.100
[17:38:24.266] Setting up SSH remote "100.100.10.100"
[17:38:24.278] Using commit id "ea3859d4ba2f3e577a159bc91e3074c5d8c0523" and quality "stable" for server
[17:38:24.285] Install and start server if needed
[17:38:25.556] Checking ssh with "ssh -V"
[17:38:25.713] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

[17:38:25.726] Running script with connection command: ssh -T -D 53538 "100.100.10.100" bash
[17:38:25.735] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[17:38:26.931] > no such identity: /home/user/.ssh/id_rsa: No such file or directory
> ]0;C:\WINDOWS\System32\cmd.exe
[17:38:26.933] Got some output, clearing connection timeout
[17:38:26.940] > root@100.100.10.100: Permission denied (publickey).
> The process tried to write to a nonexistent pipe.

As far as I can see, the issue lies with据我所知,问题在于

[17:38:26.931] > no such identity: /home/user/.ssh/id_rsa: No such file or directory

However然而

ssh -vv root@100.100.10.100 -i /home/user/.ssh/id_rsa

Successfully connects in the debug and server is accessed在调试中连接成功并访问服务器

debug1: Authentication succeeded (publickey).

So this must be some issue with specifying the location of id_rsa in the config file for VS Code.因此,在 VS Code 的配置文件中指定id_rsa的位置一定是个问题。

Host 100.100.10.100
  HostName 100.100.10.100
  User root
  ForwardAgent yes
  IdentityFile /home/autosermo/.ssh/id_rsa

We have tried everything we can think of for the value of IdentityFile (... ~/.ssh/id_rsa etc) but cannot nail it down.我们已经尝试了所有我们能想到的IdentityFile值(... ~/.ssh/id_rsa等),但无法确定。

What are the other possible locations / what path should be provided to IdentityFile here?这里还有哪些其他可能的位置/应该为IdentityFile提供什么路径?

Thank you谢谢

WSL is a bit of a red-herring here. WSL 在这里有点红鲱鱼。 When you are using the " Remote - SSH " extension in VSCode, you aren't going through WSL at all.当你在 VSCode 中使用“ Remote - SSH ”扩展时,你根本不会通过 WSL。 As you can see from this line in the output...从 output 中的这一行可以看出...

[17:38:25.713] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

... It's using OpenSSH for Windows. ...它对 Windows 使用 OpenSSH。

The location for your private key in OpenSSH should be %userprofile%/.ssh (so something like C:\Users\username\.ssh ).您的私钥在 OpenSSH 中的位置应该是%userprofile%/.ssh (类似于C:\Users\username\.ssh Try placing it there.试着把它放在那里。 Also try executing your ssh command from PowerShell or cmd rather than WSL, since that's the one being used by VSCode.还尝试从 PowerShell 或 cmd 而不是 WSL 执行ssh命令,因为这是 VSCode 使用的命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM