惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Security Latest
Security Latest
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
S
SegmentFault 最新的问题
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
P
Privacy & Cybersecurity Law Blog
WordPress大学
WordPress大学
Know Your Adversary
Know Your Adversary
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
量子位
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
雷峰网
雷峰网
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
T
Threatpost
T
Tenable Blog
有赞技术团队
有赞技术团队
大猫的无限游戏
大猫的无限游戏
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
C
Cisco Blogs
H
Heimdal Security Blog
Attack and Defense Labs
Attack and Defense Labs
A
About on SuperTechFans
Last Week in AI
Last Week in AI
N
News and Events Feed by Topic
T
Threat Research - Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
I
Intezer
V
V2EX
Cyberwarzone
Cyberwarzone
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
B
Blog RSS Feed
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
U
Unit 42
PCI Perspectives
PCI Perspectives
P
Privacy International News Feed
D
Docker

Mereith's Blog

记一次代理转发问题的排查与解决 PVE DataCenter Manager 端口号跳转错误修复 k8s + jenkins + gitlab 触发器 【转载】没有编程生产力这样的东西 【后续】居然被 ddos 了 居然被 ddos 了 Tagger - 让版本标签管理更简单 openclash 开启后端口转发失效 nextjs 启动时执行代码 买了太多VPS不知道干什么,干脆做个网站 juhost Level-1 测评 VMISS CN - Hong Kong VMISS JP - Tokyo - BGP 测评 VMISS CN - Hong Kong - BGP HomeLab 的终点是 最近在做的事情 因为选择艰难症,自己写了一套开源博客系统 手撸一个nodejs分布式爬虫,还要可视化 HomeLab 分享 我的个人工作流——开源项目推荐 动手写一个超简单的编译器 safari 插件开发 Safari Extensions Preferences 按钮无响应 设置移动端软键盘回车按钮文案 nginx proxy manager 非标准端口反代 Host 不对 监控 k8s ingress 自动添加域名 DNS 解析 使用 ingress 注解给 traefik ingress 添加中间件 使用流水线功能为文章添加固定结尾 为 VanBlog 添加一个小挂件 基于React/umi/egg自建博客系统 如何正确停止 NodeJS 子进程 k8s pod 替换策略 让威联通、pve 共享 ups 实现断电关机 Ubuntu 配置 samba 混合云部署k3s集群(基于wireguard) pve 无法启动 grub lvmid not found error antd Password 关闭自动补全 code-server node not found pve no quorum 错误 || 无法登录 pve Cannot Initiate CMAP Service pve 节点删不干净 PVE 指针(鼠标)漂移 pve 重启网络 Proxmox VE 直通显卡 ProxmoxVE (PVE) 7.0 换源升级 用 SOCAT 端口转发 git 无法 pull 仓库refusing to merge unrelated histories 用 vuepress 搭建私人知识库 js 防抖节流中的 this 与箭头函数 Dockerfile 给 Ubuntu 换源 docker 内访问宿主机 docker 删除无用镜像 css 实现展开收起动画 nginx 301 问题 Node.js 流式编程 关于我重写了三次博客项目这件事 css flex 布局超出隐藏 css 隐藏滚动条 css 文字超出隐藏并显示省略号 css 填充 svg 颜色 css 黑白滤镜 nginx 反代丢端口 docker-compose 部署 matomo 分析系统 基于 strapi 开发应用 strapi 关闭 Content Security Policy nginx 反代 rewite url Cent os 7 安装 zsh 5.6 以上版本 win11 任务栏不合并 bash 数组操作 vim 修改文件格式为 unix k8s 集群 control-plane-endpoint 主机名 git https 保存密码 Bash 判断命令存在 & 重定向 python 导出项目依赖 cent os 7 安装 gcc 版本 9 System limit for number of file watchers reached cent os 7 安装 git 2.x css 下划线中间向两边滑动效果 linux 挂载 SMB/CIFS linux 清除 ACL windows 命令行安装 inf 驱动 css 文字不可选择 iperf3 网络测速工具 cent os 换源 k8s 1.21.3 从 docker 迁移到 containerd 解决Nginx安装错误:No package nginx available 问题 从pve的硬盘里导出数据 Errors were encountered while processing adguardhome配合clash pve中使用LXC容器安装OMV LXC直通硬盘 nginx反代模版 docker常用开启容器的命令 PVE的LXC容器中安装Docker ProxmoxVE系统分区相关 基于clash搭建旁路网关 Portainer添加节点 linux声卡设置及录音音 OpenWrt用VLAN PVE换源及去掉订阅提示和改端口 adguardhome踩坑
ssh 通过跳板机访问目标机器
wanglu@mereith.com (mereith) · 2022-07-21 · via Mereith's Blog

请注意,本文编写于 1647 天前,最后修改于 1416 天前,其中某些信息可能已经过时。

有时候需要用跳板机访问机器,更安全。

对于 openssh 7.3 以上的版本可以使用 ProxyJump, 低于 7.3 可以使用 ProxyCommand

ProxyJump

需要 OpenSSH 7.3 以上版本才可以使用 ProxyJump, 使用下列命令查看OpenSSH 版本:


ProxyJump 命令行使用方法:

ssh -J [email protected]:port1,[email protected]:port2

可以直接使用上述命令通过跳板机直接登录内网机器,比如:

ssh username@目标机器IP -p 22 -J username@跳板机IP:22

如果需要通过多个跳板机则以 , 分割:

ssh username@目标机器IP -p 22 -J username1@跳板机IP1:22,username2@跳板机IP2:22

如果你觉得每次都需要加上 -J 的配置很多麻烦,可以写到配置文件里。修改配置文件 ~.ssh\config,默认没有需要自己创建。增加以下内容:

Host target # 代表目标机器的名字 HostName 目标机器 IP # 这个是目标机器的 IP Port 22 # 目标机器 ssh 的端口 User username_target # 目标机器的用户名 ProxyJump username@跳板机IP:port Host 10.10.0.* # 使用通配符 * 代表 10.10.0.1 - 10.10.0.255 Port 22 # 服务器端口 User username # 服务器用户名 ProxyJump username@跳板机IP:port

也可以为跳板机器一个“别名”方便使用:

Host tiaoban1 # 代表跳板机 1 HostName 跳板机 1 的 IP Port 22 # ssh 连接端口 User username1 # 跳板机 1 的用户名 Host tiaoban2 # 代表跳板机 2 HostName 跳板机 2 的 IP Port 22 # ssh 连接端口 User username2 # 跳板机 2 的用户名 Host target # 代表目标机器的名字 HostName 目标机器 IP # 这个是目标机器的 IP Port 22 # 目标机器 ssh 的端口 User username_target # 目标机器的用户名 ProxyJump tiaoban1,tiaoban2 Host 10.10.0.* # 使用通配符 * 代表 10.10.0.1 - 10.10.0.255 Port 22 # 服务器端口 User username # 服务器用户名 ProxyJump tiaoban1,tiaoban2

使用方法:

ssh target ssh 10.10.0.1 ssh username@target -p22 ssh username@10.10.0.1 -p22

ProxyCommand

如果 OpenSSH 版本低于 7.3 可以使用 ProxyCommand达到同样的效果。

ProxyCommand 命令行使用方法:

ssh username@目标机器IP -p 22 -o ProxyCommand='ssh -p 22 username@跳板机IP -W %h:%p'

同样可以在 ~/.ssh/config 文件中增加配置文件:

Host tiaoban # 任意名字,随便使用 HostName 跳板机的 IP,支持域名 Port 22 # 跳板机端口 User username_tiaoban # 跳板机用户 Host target # 同样,任意名字,随便起 HostName 目标服务器 IP # 真正登陆的服务器,不支持域名必须IP地址 Port 22 # 服务器的端口 User username # 服务器的用户 ProxyCommand ssh tiaoban -W %h:%p Host 10.10.0.* # 可以用*通配符 Port 22 # 服务器的端口 User username # 服务器的用户 ProxyCommand ssh tiaoban -W %h:%p

使用方法同上:

ssh target ssh 10.10.0.1 ssh username@target -p22 ssh username@10.10.0.1 -p22

参考链接

SSH 通过跳板机直接访问内网机器