Remote ssh无法连接?

1、检查ssh配置

bash 复制代码
sudo nano etc/ssh/sshd_config

确保配置

bash 复制代码
# 登录与认证
PermitRootLogin no            # 推荐 no(VS Code 不需要 root)
PasswordAuthentication yes    # yes(密码登陆)
PubkeyAuthentication yes      # 推荐同时开启(公钥登陆)
KbdInteractiveAuthentication yes
UsePAM yes

# 连接稳定性
ClientAliveInterval 30
ClientAliveCountMax 3
TCPKeepAlive yes

# VS Code / scp / sftp 必需
AllowAgentForwarding yes
AllowTcpForwarding yes
PermitTTY yes

2、检查vscode配置

设置->扩展->Remote-SSH->在json中编辑

bash 复制代码
"remote.SSH.configFile": "~/.ssh/config",配置路径
"remote.SSH.connectTimeout": 30,超时时间
"remote.SSH.path": "/usr/bin/ssh",ssh路径
"remote.SSH.localServerDownload": "always"确保vscode会远端下载失败就走本地 + scp

3、检查网络

确保远端shell没有被污染

bash 复制代码
ssh user@xxx.xxx.xxx.xx "echo OK"
# 应该输出
OK

连不上大概率是因为不能从vscode下载code server,Remote SSH插件会做这些事

bash 复制代码
1、ssh 登录(密码或密钥)
2、在远端执行:
   mkdir ~/.vscode-server
3、 检测远端 OS / 架构
4、从微软服务器下载:
   vscode-server-linux-{arch}.tar.gz
5、在远端解压如果失败则在你的电脑下载然后scp到远程解压
6、启动 node + server
7、本地 VS Code 通过 SSH 隧道连接 server

如果vscode显示正在本地下载 VS Code 服务器然后失败,说明本地电脑也无法下载,开启本地电脑全局代理即可

相关推荐
uzong10 分钟前
软件架构指南 Software Architecture Guide
后端
又是忙碌的一天10 分钟前
SpringBoot 创建及登录、拦截器
java·spring boot·后端
勇哥java实战分享1 小时前
短信平台 Pro 版本 ,比开源版本更强大
后端
学历真的很重要1 小时前
LangChain V1.0 Context Engineering(上下文工程)详细指南
人工智能·后端·学习·语言模型·面试·职场和发展·langchain
计算机毕设VX:Fegn08951 小时前
计算机毕业设计|基于springboot + vue二手家电管理系统(源码+数据库+文档)
vue.js·spring boot·后端·课程设计
上进小菜猪2 小时前
基于 YOLOv8 的智能杂草检测识别实战 [目标检测完整源码]
后端
韩师傅2 小时前
前端开发消亡史:AI也无法掩盖没有设计创造力的真相
前端·人工智能·后端
栈与堆3 小时前
LeetCode-1-两数之和
java·数据结构·后端·python·算法·leetcode·rust
superman超哥3 小时前
双端迭代器(DoubleEndedIterator):Rust双向遍历的优雅实现
开发语言·后端·rust·双端迭代器·rust双向遍历
1二山似3 小时前
crmeb多商户启动swoole时报‘加密文件丢失’
后端·swoole