【问题标题】:VS Code is not able to connect to Remote Ubuntu machine from macVS Code 无法从 mac 连接到远程 Ubuntu 机器
【发布时间】:2021-01-25 19:46:11
【问题描述】:

我正在使用 Remote-SSH 扩展并尝试从运行在 macbook 中的 vscode 连接到 ubuntu 服务器

VSCode 显示错误消息“无法获取远程环境”

并显示消息“无法连接到远程扩展主机服务器(错误:已达到时间限制)”

我已按照远程 ssh 故障排除步骤中的建议将连接超时时间增加到 60 秒,但仍然遇到此问题。

当我在 vscode 中启动会话时,我可以看到以下日志,

717b5473e20d: running
Acquiring lock on /home/usernameRedacted/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/vscode-remote-lock.usernameRedacted.e5a624b788d92b8d34d1392e4c4d9789406efe8f
Installing to /home/usernameRedacted/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f...
717b5473e20d%%1%%
Downloading with wget
Download complete
717b5473e20d%%2%%
tar --version:
tar (GNU tar) 1.30
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
Checking /home/usernameRedacted/.vscode-server/.e5a624b788d92b8d34d1392e4c4d9789406efe8f.log and /home/usernameRedacted/.vscode-server/.e5a624b788d92b8d34d1392e4c4d9789406efe8f.pid for a running server
Starting server with command... /home/usernameRedacted/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/server.sh --host=127.0.0.1 --enable-remote-auto-shutdown  --port=0 &> "/home/usernameRedacted/.vscode-server/.e5a624b788d92b8d34d1392e4c4d9789406efe8f.log" < /dev/null
printenv:
    SHELL=/bin/bash
    PWD=/home/usernameRedacted
    LOGNAME=usernameRedacted
    XDG_SESSION_TYPE=tty
    MOTD_SHOWN=pam
    HOME=/home/usernameRedacted
    LANG=en_US.UTF-8
    VSCODE_AGENT_FOLDER=/home/usernameRedacted/.vscode-server
    SSH_CONNECTION=ip1Redacted 54773 ip2Redacted 22
    XDG_SESSION_CLASS=user
    USER=usernameRedacted
    SHLVL=0
    XDG_SESSION_ID=97
    XDG_RUNTIME_DIR=/run/user/1003
    SSH_CLIENT=ip1Redacted 54773 22
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
    DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1003/bus
    OLDPWD=/home/usernameRedacted/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f
    _=/usr/bin/printenv
Spawned remote server: 272459
Waiting for server log...
 
*
* Reminder: You may only use this software with Visual Studio family products,
* as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
*
 
717b5473e20d: start
webUiAccessToken====
listeningOn==39185==
osReleaseId==ubuntu==
arch==x86_64==
tmpDir==/run/user/1003==
platform==linux==
unpackResult==success==
didLocalDownload==0==
downloadTime==402==
installTime==706==
extInstallTime====
serverStartTime==208==
717b5473e20d: end

我可以看到远程主机上正在运行以下进程

redactedUser@redactedHostname:~$ ps -ef | grep vscode
redactedUser   272459  272399  0 09:50 ?        00:00:00 sh /home/redactedUser/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/server.sh --host=127.0.0.1 --enable-remote-auto-shutdown --port=0
redactedUser   272466  272459  0 09:50 ?        00:00:00 /home/redactedUser/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/node /home/redactedUser/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/out/vs/server/main.js --host=127.0.0.1 --enable-remote-auto-shutdown --port=0

另外,这里是服务器日志

redactedUser@redactedHostname:~$ cat ~/.vscode-server/.e5a624b788d92b8d34d1392e4c4d9789406efe8f.log


*
* Visual Studio Code Server
*
* Reminder: You may only use this software with Visual Studio family products,
* as described in the license https://aka.ms/vscode-remote/license
*


IP Address: redacted
Extension host agent listening on 39185


[09:50:19] Extension host agent started.

我该如何解决这个问题?

【问题讨论】:

    标签: linux macos ssh vscode-remote


    【解决方案1】:

    导致此问题的隧道已禁用。

    作为修复,我必须通过编辑 /etc/sshd_config 来启用隧道

    以下设置为我解决了这个问题:

    Github 相关问题:https://github.com/microsoft/vscode-remote-release/issues/4176

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-12-22
      • 2011-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-15
      • 1970-01-01
      相关资源
      最近更新 更多