VS Code Remot-SSH连接及各种报错集合
VS Code Remot-SSH连接实现服务器环境运行调测Python 和shell脚本
一、VS Code Remot-SSH 连接
1、安装Remot-SSH 插件
在VS Code页面做侧菜单扩展-》搜索remote -》找到安装Remote-SSH-》点击安装
安装完后点击左下角绿色><远程窗口
扩展-》搜索remote ->安装Remote-SSH:
安装完后点击左下角连接》选择Connect Current Window to Host Remote-SSH
添加主机:Add New SSH Host
输入 ssh root@IP
打开设置,
本地CMD生成私钥
将私钥拷贝到服务的.ssh/authorized_keys 文件中
实现免密码登录
[10:52:56.264] Log Level: 2
[10:52:56.271] remote-ssh@0.65.4
[10:52:56.271] win32 x64
[10:52:56.272] SSH Resolver called for “ssh-remote+192.168.1.100”, attempt 1
[10:52:56.272] “remote.SSH.useLocalServer”: false
[10:52:56.272] “remote.SSH.showLoginTerminal”: false
[10:52:56.273] “remote.SSH.remotePlatform”: {“cloud”:“linux”,“cloud112”:“linux”,“192.168.1.20”:“linux”}
[10:52:56.273] “remote.SSH.path”: undefined
[10:52:56.273] “remote.SSH.configFile”: undefined
[10:52:56.273] “remote.SSH.useFlock”: true
[10:52:56.273] “remote.SSH.lockfilesInTmp”: false
[10:52:56.274] “remote.SSH.localServerDownload”: auto
[10:52:56.274] “remote.SSH.remoteServerListenOnSocket”: false
[10:52:56.274] “remote.SSH.showLoginTerminal”: false
[10:52:56.274] “remote.SSH.defaultExtensions”: []
[10:52:56.274] “remote.SSH.loglevel”: 2
[10:52:56.274] SSH Resolver called for host: 192.168.1.100
[10:52:56.275] Setting up SSH remote “192.168.1.100”
[10:52:56.317] Using commit id “054a9295330880ed74ceaedda236253b4f39a335” and quality “stable” for server
[10:52:56.320] Install and start server if needed
[10:52:59.731] getPlatformForHost was canceled
[10:52:59.732] Resolver error: Error: Connecting was canceled
at Function.Canceled (c:\Users\Digital.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.4\out\extension.js:1:64837)
at c:\Users\Digital.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.4\out\extension.js:1:294430
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Object.t.withShowDetailsEvent (c:\Users\Digital.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.4\out\extension.js:1:405329)
at async Object.t.resolve (c:\Users\Digital.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.4\out\extension.js:1:295639)
at async c:\Users\Digital.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.4\out\extension.js:127:110530
[10:52:59.738] ------
报错:Resolver error: Error: Connecting was canceled
解决:点击文件-》首选项-》设置打开设置窗口,点击右上角
在大括号内加入:
“remote.SSH.remotePlatform”: {
“连接名称”: “linux”,
}
报错:VS Code 无法连接到远程扩展主机服务器 (错误: WebSocket close with status code 1006)
控制台:能连上服务器,服务器上有.vscode文件夹,channel 3: open failed: administratively prohibited: open failed
服务器执行脚本vscode-server Ignoring option h-remote-auto-shutdown: not supported for server
解决: vi /etc/ssh/sshd_config
将:AllowTcpForwarding yes #注释去掉,改成 yes
重启 sshd服务:systemctl restart sshd