背景:昨天我用vscode使用ssh远程开发还处于正常状态,今天刚打开电脑,并启动deepin,再次使用vscode重新连接就出现异常。
报错信息如下:
[17:30:45.135] Log Level: 2
[17:30:45.163] SSH Resolver called for "ssh-remote+connectdeepin", attempt 1
[17:30:45.164] "remote.SSH.useLocalServer": false
[17:30:45.165] "remote.SSH.showLoginTerminal": true
[17:30:45.165] "remote.SSH.remotePlatform": {"connectdeepin":"linux"}
[17:30:45.166] "remote.SSH.path": undefined
[17:30:45.166] "remote.SSH.configFile": undefined
[17:30:45.166] "remote.SSH.useFlock": true
[17:30:45.166] "remote.SSH.lockfilesInTmp": false
[17:30:45.167] "remote.SSH.localServerDownload": auto
[17:30:45.167] "remote.SSH.remoteServerListenOnSocket": false
[17:30:45.167] "remote.SSH.showLoginTerminal": true
[17:30:45.167] "remote.SSH.defaultExtensions": []
[17:30:45.167] "remote.SSH.loglevel": 2
[17:30:45.168] "remote.SSH.enableDynamicForwarding": true
[17:30:45.168] "remote.SSH.enableRemoteCommand": false
[17:30:45.172] "remote.SSH.serverPickPortsFromRange": {}
[17:30:45.173] "remote.SSH.serverInstallPath": {}
[17:30:45.183] VS Code version: 1.79.2
[17:30:45.183] Remote-SSH version: remote-ssh@0.102.0
[17:30:45.183] win32 x64
[17:30:45.185] SSH Resolver called for host: connectdeepin
[17:30:45.185] Setting up SSH remote "connectdeepin"
[17:30:45.194] Using commit id "695af097c7bd098fbf017ce3ac85e09bbc5dda06" and quality "stable" for server
[17:30:45.201] Install and start server if needed
[17:30:45.215] Checking ssh with "D:\VMware\bin\ssh.exe -V"
[17:30:45.223] Got error from ssh: spawn D:\VMware\bin\ssh.exe ENOENT
[17:30:45.227] Checking ssh with "C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe -V"
[17:30:45.231] Got error from ssh: spawn C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe ENOENT
[17:30:45.232] Checking ssh with "C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\ssh.exe -V"
[17:30:45.236] Got error from ssh: spawn C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\ssh.exe ENOENT
[17:30:45.236] Checking ssh with "C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\ssh.exe -V"
[17:30:45.240] Got error from ssh: spawn C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\ssh.exe ENOENT
[17:30:45.241] Checking ssh with "C:\Windows\system32\ssh.exe -V"
[17:30:45.246] Got error from ssh: spawn C:\Windows\system32\ssh.exe ENOENT
[17:30:45.246] Checking ssh with "C:\Windows\ssh.exe -V"
[17:30:45.250] Got error from ssh: spawn C:\Windows\ssh.exe ENOENT
[17:30:45.251] Checking ssh with "C:\Windows\System32\Wbem\ssh.exe -V"
[17:30:45.261] Got error from ssh: spawn C:\Windows\System32\Wbem\ssh.exe ENOENT
[17:30:45.262] Checking ssh with "C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe -V"
[17:30:45.274] Got error from ssh: spawn C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT
[17:30:45.283] Checking ssh with "C:\Windows\System32\OpenSSH\ssh.exe -V"
[17:30:45.532] > OpenSSH_for_Windows_8.1p
[17:30:45.532] > 1, LibreSSL 3.0.2
[17:30:45.541] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 55154 connectdeepin bash
[17:30:45.545] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[17:30:46.194] > ]0;C:\WINDOWS\System32\cmd.exe
[17:30:46.194] Got some output, clearing connection timeout
[17:30:46.203] >
>
>
>
>
>
>
>
>
[17:30:48.248] > ssh: connect to host connectdeepin port 22: Connection refused
[17:30:48.264] > 过程试图写入的管道不存在。
[17:30:49.551] "install" terminal command done
[17:30:49.552] Install terminal quit with output: 过程试图写入的管道不存在。
[17:30:49.552] Received install output: 过程试图写入的管道不存在。
[17:30:49.553] Failed to parse remote port from server output
[17:30:49.556] Resolver error: Error:
at m.Create (c:\Users\xx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:584145)
at t.handleInstallOutput (c:\Users\xx.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:582705)
at t.tryInstall (c:\Users\xx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:681881)
at async c:\Users\xx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:644110
at async t.withShowDetailsEvent (c:\Users\xx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:647428)
at async t.resolve (c:\Users\xx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:645160)
at async c:\Users\xx\.vscode\extensions\ms-vscode-remote.remote-ssh-0.102.0\out\extension.js:1:720916
[17:30:49.572] -----
我在网络上找了很多前辈的博客借鉴,发现自己的情况和前辈们都不太一样,然后仔细的分析了报错信息中有用的部分,如下:
[17:30:45.135] Log Level: 2
[17:30:48.248] > ssh: connect to host connectdeepin port 22: Connection refused
[17:30:48.264] > 过程试图写入的管道不存在。
意思就是22号默认端口连接被拒绝,所以要先确定ssh是否连接
解决步骤如下:
1.检查sshd是否启动
service sshd restart
如果像我一样,执行后报错了,就执行下面的命令安装并重启sshd:
sudo apt install openssh-server
systemctl enable ssh.service
service sshd restart
2.查看22号端口
执行cat /etc/ssh/sshd_config
,查看port后面的端口号是不是22号
3.重新进入vscode里面,重新连接,如图成功连接
开森~