VSCode远程SSH连接失败

时间:2020-03-03 12:52:54

标签: ssh visual-studio-code remote-debugging vscode-remote

我正在尝试使用Remote-SSH扩展来编辑Debian服务器上的文件。 SSH连接已正确建立,但随后出现错误消息:

Failed to connect to the remote extension host server

还有日志:

[13:19:04.182] Remote server is listening on port 51569
[13:19:04.182] Parsed server configuration: {"agentPort":51569,"osReleaseId":"debian","arch":"x86_64","webUiAccessToken":"","sshAuthSock":"","tmpDir":"/tmp"}
[13:19:04.184] Starting forwarding server. localPort 59828 -> socksPort 59825 -> remotePort 51569
[13:19:04.185] Forwarding server listening on 59828
[13:19:04.185] Waiting for ssh tunnel to be ready
[13:19:04.186] Tunneled remote port 51569 to local port 59828
[13:19:04.186] Resolved "ssh-remote+home-debian.web-data.host" to "127.0.0.1:59828"
[13:19:04.187] [Forwarding server 59828] Got connection 0
[13:19:04.195] ------
[13:19:04.208] [Forwarding server 59828] Got connection 1
[13:19:04.208] [Forwarding server 59828] Got connection 2
[13:19:04.217] Failed to set up socket for dynamic port forward to remote port 51569: Socket closed. Is the remote port correct?
[13:19:04.227] > channel 3: open failed: administratively prohibited: open failed
[13:19:04.235] Failed to set up socket for dynamic port forward to remote port 51569: Socket closed. Is the remote port correct?
[13:19:04.237] Failed to set up socket for dynamic port forward to remote port 51569: Socket closed. Is the remote port correct?
[13:19:04.241] > channel 4: open failed: administratively prohibited: open failed
> channel 5: open failed: administratively prohibited: open failed

我正在其他几台服务器上使用远程ssh连接,但从未遇到此错误。我已经测试了一些从网络上搜集到的东西,但到目前为止没有任何工作。

有人可以启发我解决问题的原因或可能的解决方案吗?谢谢!

4 个答案:

答案 0 :(得分:4)

Delete '~/.vscode-server' folder on your server, and try reconnect.

不确定Debian服务器,但这在Ubuntu 18.04上有效

答案 1 :(得分:2)

[13:19:04.227] > channel 3: open failed: administratively prohibited: open failed

您要连接的远程服务器拒绝为您执行端口转发。假设远程服务器是OpenSSH,则可以在远程服务器上的两个地方进行配置:

  1. 服务器可能配置为不允许通过sshd_config选项PermitOpenDisableForwarding选项进行端口转发。
  2. 如果您正在使用ssh密钥进行身份验证,则可以通过authorized_keys选项PermitOpenrestrict禁用转发。

答案 2 :(得分:1)

将sshd_config中的AllowTcpForwardingno更改为yes,然后重新启动sshd对我来说是可行的。

经过Raspbian GNU/Linux 10 (buster)

的测试

答案 3 :(得分:1)

FWIW;我遇到了同样的问题,重新启动似乎可以解决问题。