Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
571 views
in Technique[技术] by (71.8m points)

visual studio code - 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:

[17:38:24.258] Log Level: 2
[17:38:24.260] [email protected]
[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:WINDOWSSystem32cmd.exe
[17:38:26.931] > no such identity: /home/user/.ssh/id_rsa: No such file or directory
> ]0;C:WINDOWSSystem32cmd.exe
[17:38:26.933] Got some output, clearing connection timeout
[17:38:26.940] > [email protected]: 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 [email protected] -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.

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.

What are the other possible locations / what path should be provided to IdentityFile here?

Thank you

question from:https://stackoverflow.com/questions/65874125/connecting-to-remote-linux-server-with-vscode-through-wsl-file-location-issue

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

WSL is a bit of a red-herring here. When you are using the "Remote - SSH" extension in VSCode, you aren't going through WSL at all. As you can see from this line in the output ...

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

... It's using OpenSSH for Windows.

The location for your private key in OpenSSH should be %userprofile%/.ssh (so something like C:Usersusername.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...