VSCode Remote-SSH无法连接gadi服务器,但终端连接正常求助
VSCode Remote-SSH连接gadi.nci.org.au失败问题解决
问题描述
使用VSCode Remote-SSH扩展尝试连接远程服务器gadi.nci.org.au,连接命令为ssh -X ln2626@gadi.nci.org.au,但VSCode提示“Could not establish connection to 'gadi.nci.org.au'”错误。终端执行相同命令可正常连接,且该方法连接其他服务器无异常。本地系统为Linux和Windows,远程服务器为Linux。
连接日志
[00:38:05.726] Log Level: 2 [00:38:05.741] SSH Resolver called for "ssh-remote+gadi.nci.org.au", attempt 1 [00:38:05.742] "remote.SSH.useLocalServer": true [00:38:05.743] "remote.SSH.path": undefined [00:38:05.743] "remote.SSH.configFile": undefined [00:38:05.743] "remote.SSH.useFlock": true [00:38:05.743] "remote.SSH.lockfilesInTmp": false [00:38:05.744] "remote.SSH.localServerDownload": auto [00:38:05.744] "remote.SSH.remoteServerListenOnSocket": false [00:38:05.744] "remote.SSH.showLoginTerminal": false [00:38:05.744] "remote.SSH.defaultExtensions": [] [00:38:05.745] "remote.SSH.loglevel": 2 [00:38:05.745] "remote.SSH.enableDynamicForwarding": true [00:38:05.745] "remote.SSH.enableRemoteCommand": false [00:38:05.746] "remote.SSH.serverPickPortsFromRange": {} [00:38:05.746] "remote.SSH.serverInstallPath": {} [00:38:05.754] VS Code version: 1.81.1 [00:38:05.754] Remote-SSH version: remote-ssh@0.105.2023080715 [00:38:05.754] linux x64 [00:38:05.756] SSH Resolver called for host: gadi.nci.org.au [00:38:05.756] Setting up SSH remote "gadi.nci.org.au" [00:38:05.760] Acquiring local install lock: /tmp/vscode-remote-ssh-7b8c0aaa-install.lock [00:38:05.763] Looking for existing server data file at /home/lu/.config/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-7b8c0aaa-6c3e3dba23e8fadc360aed75ce363ba185c49794-0.105.2023080715/data.json [00:38:05.763] Using commit id "6c3e3dba23e8fadc360aed75ce363ba185c49794" and quality "stable" for server [00:38:05.771] Install and start server if needed [00:38:05.774] PATH: /usr/condabin:/usr/local/sbin:/usr/local/bin:/usr/bin:/home/lu/AMD:/opt/cuda/bin:/opt/cuda/nsight_compute:/opt/cuda/nsight_systems/bin:/home/lu/.dotnet/tools:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl [00:38:05.774] Checking ssh with "ssh -V" [00:38:05.788] > OpenSSH_9.4p1, OpenSSL 3.1.2 1 Aug 2023 [00:38:05.794] askpass server listening on /run/user/1000/vscode-ssh-askpass-026934159dee6eab7dc05f0512243bea20c2e1e5.sock [00:38:05.794] Spawning local server with {"serverId":1,"ipcHandlePath":"/run/user/1000/vscode-ssh-askpass-04cc79644a8074c9bf8655aea9e95d1462187b03.sock","sshCommand":"ssh","sshArgs":["-v","-T","-D","40853","-o","ConnectTimeout=15","gadi.nci.org.au"],"serverDataFolderName":".vscode-server","dataFilePath":"/home/lu/.config/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-7b8c0aaa-6c3e3dba23e8fadc360aed75ce363ba185c49794-0.105.2023080715/data.json"} [00:38:05.794] Local server env: {"SHELL":"/bin/zsh","DISPLAY":":0","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"/home/lu/.vscode/extensions/ms-vscode-remote.remote-ssh-0.105.2023080715/out/local-server/askpass.sh","VSCODE_SSH_ASKPASS_NODE":"/opt/visual-studio-code/code","VSCODE_SSH_ASKPASS_EXTRA_ARGS":"--ms-enable-electron-run-as-node","VSCODE_SSH_ASKPASS_MAIN":"/home/lu/.vscode/extensions/ms-vscode-remote.remote-ssh-0.105.2023080715/out/askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"/run/user/1000/vscode-ssh-askpass-026934159dee6eab7dc05f0512243bea20c2e1e5.sock"} [00:38:05.800] Spawned 31026 [00:38:05.968] > local-server-1> Running ssh connection command: "-v -T -D 40853 -o ConnectTimeout=15 gadi.nci.org.au" [00:38:05.974] > local-server-1> Spawned ssh, pid=31034 [00:38:05.979] stderr> OpenSSH_9.4p1, OpenSSL 3.1.2 1 Aug 2023 [00:38:06.081] stderr> debug1: Server host key: ssh-ed25519 SHA256:4VAftRK1D11TnXKVeWDsb/wonDJXW6p5Bt0J5XH4T+s [00:38:06.298] Got askpass request: {"request":"ln2626@gadi.nci.org.au's password:"} [00:38:06.298] Showing password prompt [00:38:06.299] Listening for interwindow password on /run/user/1000/vscode-ssh-askpass-64868002ff2f88c3f58f1a20a39d69c3efa9798b.sock [00:38:06.299] Writing password prompt to globalState [00:38:10.297] Got password response [00:38:10.298] Interactor gave response: ******** [00:38:10.299] Cleaning up other-window auth server [00:38:10.384] stderr> Authenticated to gadi.nci.org.au ([203.0.19.85]:22) using "password". [00:38:10.905] > ############################################################################### > # Welcome to the NCI National Facility! # > # This service is for authorised clients only. It is a criminal # > # offence to: # > # - Obtain access to data without permission # > # - Damage, delete, alter or insert data without permission # > # Use of this system requires acceptance of the Conditions of Use # > # published at http://nci.org.au/users/nci-terms-and-conditions-access # > ############################################################################### > | gadi.nci.org.au - 260,760 processor InfiniBand x86_64 cluster | > =============================================================================== > > Oct 4 2022 Account Status Information on Login > Whenever logging in from outside of Gadi, all users will now be presented > with a brief summary about file expiry and projects near compute and/or > storage quotas. This can be configured using the "login-info-conf" utility. > For more information, please see https://opus.nci.org.au/x/HoABCw. > > Mar 21 Sapphire Rapids Nodes Available > An expansion to the CPU capacity of Gadi is now available with the addition > of 720 Intel Xeon Sapphire Rapids nodes to Gadi. These nodes are available > in the "normalsr" and "expresssr" queues. > > For more information, please see https://opus.nci.org.au/x/gIDAD > =============================================================================== [00:38:11.422] > ready: 12b6d282c9b6 [00:38:11.433] > Linux 4.18.0-477.15.1.el8.nci.x86_64 #1 SMP Sun Jul 16 11:36:47 AEST 2023 [00:38:11.434] Platform: linux [00:38:11.442] > /bin/bash [00:38:11.442] Shell: bash [00:38:11.443] Creating bash subshell inside "bash" [00:38:11.500] > bash version: 4.4.20(1)-release [00:38:11.509] > bash version: 4.4.20(1)-release [00:38:11.532] > 12b6d282c9b6: running [00:38:11.579] > Creating the server install dir failed... > 12b6d282c9b6: start > exitCode==34== > listeningOn==== > osReleaseId==== > arch==== > vscodeArch==== > bitness==== > tmpDir==/run/user/15456== > platform==== > unpackResult==== > didLocalDownload==0== > downloadTime==== > installTime==== > extInstallTime==== > serverStartTime==== > 12b6d282c9b6: end [00:38:11.580] Received install output: exitCode==34== listeningOn==== osReleaseId==== arch==== vscodeArch==== bitness==== tmpDir==/run/user/15456== platform==== unpackResult==== didLocalDownload==0== downloadTime==== installTime==== extInstallTime==== serverStartTime==== [00:38:11.582] Failed to parse remote port from server output [00:38:11.582] Terminating local server [00:38:11.591] Resolver error: Error: at m.Create (/home/lu/.vscode/extensions/ms-vscode-remote.remote-ssh-0.105.2023080715/out/extension.js:2:617971) at t.handleInstallOutput (/home/lu/.vscode/extensions/ms-vscode-remote.remote-ssh-0.105.2023080715/out/extension.js:2:616531) at Object.e [as tryInstallWithLocalServer] (/home/lu/.vscode/extensions/ms-vscode-remote.remote-ssh-0.105.2023080715/out/extension.js:2:674803) at process.processTicksAndRejections (node:internal/process/task_queues:96:5) at async /home/lu/.vscode/extensions/ms-vscode-remote.remote-ssh-0.105.2023080715/out/extension.js:2:696433 at async t.withShowDetailsEvent (/home/lu/.vscode/extensions/ms-vscode-remote.remote-ssh-0.105.2023080715/out/extension.js:2:699849) at async /home/lu/.vscode/extensions/ms-vscode-remote.remote-ssh-0.105.2023080715/out/extension.js:2:673275 at async C (/home/lu/.vscode/extensions/ms-vscode-remote.remote-ssh-0.105.2023080715/out/extension.js:2:669763) at async t.resolveWithLocalServer (/home/lu/.vscode/extensions/ms-vscode-remote.remote-ssh-0.105.2023080715/out/extension.js:2:672872) at async A (/home/lu/.vscode/extensions/ms-vscode-remote.remote-ssh-0.105.2023080715/out/extension.js:2:693642) at async t.resolve (/home/lu/.vscode/extensions/ms-vscode-remote.remote-ssh-0.105.2023080715/out/extension.js:2:697405) at async /home/lu/.vscode/extensions/ms-vscode-remote.remote-ssh-0.105.2023080715/out/extension.js:2:879896 [00:38:11.595] ------ [00:38:11.602] Local server exit: 15
错误核心分析
从日志中的Creating the server install dir failed...和exitCode==34==可以明确:VSCode Remote-SSH已成功建立SSH连接,但在远程服务器创建.vscode-server目录时失败,导致无法启动远程服务端,最终连接中断。
排查与解决建议
- 检查用户主目录权限:登录远程服务器后执行
ls -ld ~,确保主目录权限为drwx------(700)。若权限异常,执行chmod 700 ~修正,避免VSCode无法在主目录下创建子目录。 - 手动创建.vscode-server目录:登录远程服务器后,执行
mkdir -p ~/.vscode-server,再设置权限chmod 700 ~/.vscode-server,完成后重新尝试VSCode连接。 - 禁用VSCode本地服务器:在VSCode设置中搜索
remote.SSH.useLocalServer,将其设为false。部分服务器环境与VSCode本地服务器存在兼容性问题,禁用后可直接通过SSH会话部署远程服务端。 - 检查远程临时目录权限:日志显示临时目录为
/run/user/15456,登录远程后确认该目录存在且当前用户有读写权限。若目录不存在,手动创建mkdir -p /run/user/15456并设置权限chmod 700 /run/user/15456。 - 切换为SSH密钥登录:终端密码登录正常,但VSCode会话环境可能存在差异。生成SSH密钥对
ssh-keygen,将公钥复制到远程服务器的~/.ssh/authorized_keys文件中,并设置该文件权限为600,之后用密钥登录VSCode。
内容的提问来源于stack exchange,提问
相关产品推荐
相关产品推荐

