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 服务器然后失败,说明本地电脑也无法下载,开启本地电脑全局代理即可

相关推荐
码界奇点13 小时前
基于Spring Boot和Vue3的无头内容管理系统设计与实现
java·spring boot·后端·vue·毕业设计·源代码管理
To Be Clean Coder14 小时前
【Spring源码】createBean如何寻找构造器(二)——单参数构造器的场景
java·后端·spring
你才是臭弟弟14 小时前
SpringBoot 集成MinIo(根据上传文件.后缀自动归类)
java·spring boot·后端
C澒14 小时前
面单打印服务的监控检查事项
前端·后端·安全·运维开发·交通物流
鸣潮强于原神14 小时前
TSMC chip_boundary宽度规则解析
后端
Code blocks14 小时前
kingbase数据库集成Postgis扩展
数据库·后端
Elieal15 小时前
JWT 登录校验机制:5 大核心类打造 Spring Boot 接口安全屏障
spring boot·后端·安全
czlczl2002092515 小时前
Spring Boot Filter :doFilter 与 doFilterInternal 的差异
java·spring boot·后端
码界奇点15 小时前
基于Spring Boot和Activiti6的工作流OA系统设计与实现
java·spring boot·后端·车载系统·毕业设计·源代码管理
yangminlei15 小时前
Spring Boot拦截器(Interceptor)与过滤器(Filter)深度解析:区别、实现与实战指南
java·spring boot·后端