首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过VSCode连接到远程linux服务器-文件定位问题?

通过VSCode连接到远程linux服务器-文件定位问题?
EN

Stack Overflow用户
提问于 2021-01-25 02:02:10
回答 1查看 181关注 0票数 1

当尝试使用VS Code / WSL远程访问作为Digital Ocean droplet托管的linux服务器时,我们收到以下错误:

代码语言:javascript
复制
[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.

据我所知,问题出在

代码语言:javascript
复制
[17:38:26.931] > no such identity: /home/user/.ssh/id_rsa: No such file or directory

然而,

代码语言:javascript
复制
ssh -vv root@100.100.10.100 -i /home/user/.ssh/id_rsa

在调试中成功连接并访问服务器

代码语言:javascript
复制
debug1: Authentication succeeded (publickey).

因此,在VS代码的配置文件中指定id_rsa的位置一定有问题。

代码语言:javascript
复制
Host 100.100.10.100
  HostName 100.100.10.100
  User root
  ForwardAgent yes
  IdentityFile /home/autosermo/.ssh/id_rsa

我们已经尝试了所有我们能想到的IdentityFile (...,~/.ssh/id_rsa等)的值,但都无法确定。

这里还有哪些其他可能的位置/应该提供到IdentityFile的路径?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2021-01-25 03:17:45

当您在VSCode中使用"Remote - SSH“扩展时,您根本不需要使用WSL。

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

..。它使用的是Windows的OpenSSH。

您的私钥在OpenSSH中的位置应该是%userprofile%/.ssh (所以类似于C:\Users\username\.ssh)。试着把它放在那里。另外,尝试从PowerShell或cmd而不是WSL执行ssh命令,因为这是VSCode正在使用的命令。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65874125

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档