我在vmware装了一个linux虚拟机,用vscode remote远程可以正常连接虚拟机。
为了实现自动化,我用vmrun命令行工具no gui方式启动虚拟机,然后再用vscode remote连接虚拟机,但是总是连接失败,但如果我打开finalshell,就又可以连接了,一关闭finalshell,vscode的远程连接就会断,请问这是为什么?
关闭finalshell后,vscode断连出现的报错日志。
[21:38:11.185] Log Level: 2
[21:38:11.201] VS Code version: 1.81.1
[21:38:11.201] Remote-SSH version: remote-ssh@0.102.0
[21:38:11.201] win32 x64
[21:38:11.206] SSH Resolver called for "ssh-remote+terminal", attempt 1
[21:38:11.206] "remote.SSH.useLocalServer": false
[21:38:11.207] "remote.SSH.showLoginTerminal": true
[21:38:11.207] "remote.SSH.remotePlatform": {"terminal":"linux"}
[21:38:11.207] "remote.SSH.path": undefined
[21:38:11.207] "remote.SSH.configFile": undefined
[21:38:11.207] "remote.SSH.useFlock": true
[21:38:11.208] "remote.SSH.lockfilesInTmp": false
[21:38:11.208] "remote.SSH.localServerDownload": auto
[21:38:11.208] "remote.SSH.remoteServerListenOnSocket": false
[21:38:11.208] "remote.SSH.showLoginTerminal": true
[21:38:11.208] "remote.SSH.defaultExtensions": []
[21:38:11.208] "remote.SSH.loglevel": 2
[21:38:11.209] "remote.SSH.enableDynamicForwarding": true
[21:38:11.209] "remote.SSH.enableRemoteCommand": false
[21:38:11.209] "remote.SSH.serverPickPortsFromRange": {}
[21:38:11.209] "remote.SSH.serverInstallPath": {}
[21:38:11.215] SSH Resolver called for host: terminal
[21:38:11.215] Setting up SSH remote "terminal"
[21:38:11.223] Using commit id "6c3e3dba23e8fadc360aed75ce363ba185c49794" and quality "stable" for server
[21:38:11.226] Install and start server if needed
[21:38:11.231] Checking ssh with "C:\Program Files (x86)\VMware\VMware Workstation\bin\ssh.exe -V"
[21:38:11.233] Got error from ssh: spawn C:\Program Files (x86)\VMware\VMware Workstation\bin\ssh.exe ENOENT
[21:38:11.233] Checking ssh with "C:\Windows\system32\ssh.exe -V"
[21:38:11.235] Got error from ssh: spawn C:\Windows\system32\ssh.exe ENOENT
[21:38:11.235] Checking ssh with "C:\Windows\ssh.exe -V"
[21:38:11.236] Got error from ssh: spawn C:\Windows\ssh.exe ENOENT
[21:38:11.236] Checking ssh with "C:\Windows\System32\Wbem\ssh.exe -V"
[21:38:11.237] Got error from ssh: spawn C:\Windows\System32\Wbem\ssh.exe ENOENT
[21:38:11.237] Checking ssh with "C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe -V"
[21:38:11.238] Got error from ssh: spawn C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT
[21:38:11.239] Checking ssh with "C:\Windows\System32\OpenSSH\ssh.exe -V"
[21:38:11.278] > OpenSSH_for_Windows_8.6p1, LibreSSL 3.4.3
[21:38:11.281] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 52040 terminal bash
[21:38:11.283] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[21:38:28.290] Resolver error: Error: Connecting with SSH timed out
at m.Timeout (c:\Users\廖志荣\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:584271)
at Timeout._onTimeout (c:\Users\廖志荣\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:680601)
at listOnTimeout (node:internal/timers:559:17)
at process.processTimers (node:internal/timers:502:7)
[21:38:28.298] ------
[21:38:32.668] > ssh: connect to host 192.168.217.128 port 22: Connection timed out
> 过程试图写入的管道不存在。
> ]0;C:\WINDOWS\System32\cmd.exe
[21:38:32.669] Got some output, clearing connection timeout
[21:38:33.938] "install" terminal command done
[21:38:33.938] Install terminal quit with output: ]0;C:\WINDOWS\System32\cmd.exe
finalshell是运行在linux上的应用软件吗?
【以下回答由 GPT 生成】
这个问题可能是由于SSH服务在虚拟机中断开导致的。 以下是解决该问题的步骤:
sudo service ssh status
如果SSH服务未运行,请使用以下命令启动它:
sudo service ssh start
检查虚拟机的网络设置。确保虚拟机的网络配置正确,并且网络连接是稳定的。
检查VSCode的SSH配置。确保VSCode的SSH配置正确,特别是检查远程连接的主机名、端口号、用户名和密码或密钥。
检查防火墙设置。如果在虚拟机上启用了防火墙,确保允许进入的SSH连接。可以通过在虚拟机中运行以下命令来检查防火墙设置:
sudo iptables -L
如果防火墙阻止SSH连接,请使用以下命令允许SSH连接:
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo nano /etc/ssh/sshd_config
确保以下设置正确:
Port 22
PermitRootLogin yes
PasswordAuthentication yes
如果上述步骤没有解决问题,请在虚拟机和VSCode的日志中查找更多信息。此外,可以尝试使用其他SSH工具(如PuTTY)来连接虚拟机,以确定问题是否出在VSCode本身。
希望这些步骤能帮助解决你的问题。如果仍然存在问题,请提供更多详细信息,以便我们能够更好地帮助你解决。