ssh 通过代理机跳转内网

ssh 通过代理机跳转内网
(1)ssh使用跳转
$ ssh -J user@jump-host:port <user@remote: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这行不用跟着变化.

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值