简体   繁体   English

VS Code 无法从 mac 连接到远程 Ubuntu 机器

[英]VS Code is not able to connect to Remote Ubuntu machine from mac

I am using the Remote-SSH extension and trying to connect to a ubuntu server from vscode running in a macbook我正在使用Remote-SSH扩展并尝试从在 macbook 中运行的 vscode 连接到 ubuntu 服务器

VSCode shows the error message "Could not fetch the remote environment" VSCode 显示错误消息“无法获取远程环境”

And shows the message "Failed to connect to the remote extension host server (Error: Time limit reached)"并显示消息“无法连接到远程扩展主机服务器(错误:已达到时间限制)”

I have increased the connection timeout to 60s as suggested in the remote ssh troubleshooting steps, but still face this issue.我已按照远程 ssh 故障排除步骤中的建议将连接超时时间增加到 60 秒,但仍然面临这个问题。

When I start the session in vscode, I can see the following logs,当我在vscode中启动session时,可以看到如下日志,

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

I can see the following process running on the remote host我可以看到远程主机上正在运行以下进程

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

Also, here is the server log另外,这是服务器日志

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.

How can I fix this?我怎样才能解决这个问题?

Tunneling was disabled which caused this issue.导致此问题的隧道已禁用。

As a fix I had to enable Tunneling by editing /etc/sshd_config作为修复,我必须通过编辑 /etc/sshd_config 来启用隧道

Following settings fixed the issue for me:以下设置为我解决了这个问题:

在此处输入图像描述

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

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

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