栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

ssh 通过代理机跳转内网

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ssh 通过代理机跳转内网

ssh 通过代理机跳转内网
(1)ssh使用跳转
$ ssh -J user@jump-host:port

(2)proxyjump
vscode使用proxyjump时,连接中转服务器后报错:
channel 0: open failed: administratively prohibited: open failed
stdio forwarding failed
kex_exchange_identification: Connection closed by remote host

解决方法1:(成功)
Host customer
Hostname customer.whatever.com <–跳板主板主机要能正确解析hostname才行,否则请填IP
User linuxuser
ForwardAgent
yes Port 22
ProxyCommand ssh user1@jump.linux.com -p 5566 nc %h %p

(ref:
https://shazi.info/%E5%88%A9%E7%94%A8ssh-proxycommand%E5%8F%8Anc%E5%81%9A%E8%B7%B3%E6%9D%BF%E7%9A%84%E9%80%A3%E7%B7%9A%E6%87%89%E7%94%A8/)

解决方法2:(该解决方法不知是否可行)
/etc/ssh/sshd_config
AllowTcpForwarding yes
(但是没有root权限无法操作)

(3)proxycommand使用例子
Host tiaoban
Hostname 跳板机的ip
Port 跳板机的端口(如果是非22的需要填写)
User root(如果非root,换成跳板机的用户)
Host mubiaoji
Hostname 目标机的IP
Port 跳板机的端口(如果是非22的需要填写)
User root(如果非root,换成跳板机的用户)
ProxyCommand ssh -q -x -W %h:%p tiaoban (该方法使用报错:kex_exchange_identification: Connection closed by remote host)
(成功的方法请参考上边成功的方法)

这儿的%h表示要连接的目标机,也就是Hostname指定的ip或者主机名,%p表示要连接到目标机的端口.这儿可以直接写死固定值,但是使用%h和%p可以保证在Hostname和Port变化的情况下ProxyCommand这行不用跟着变化.

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/599335.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号