ssh-tunnel - 复杂的 SSH 隧道
问题描述
我有一个复杂的 SSH 隧道问题,我正在尝试解决,但似乎无法完全正确。
简单的说:
ME -> 堡垒:22 -> 实例:8500
Bastion 使用与实例不同的用户名和密钥。我希望能够从 localhost:1234 访问实例上的端口 1234
现在我有以下内容:
Host bastion
HostName bastion.example.com
ForwardAgent yes
IdentityFile ~/.ssh/id_ecdsa
User spanky
Host internal
ForwardAgent yes
HostName consul.internal
IdentityFile ~/.ssh/aws.pem
ProxyJump bastion
User ec2-user
Port 8500
但我不认为我得到它。
以下两个命令有效,但我试图将它们提炼成一个工作配置:
ssh -L 2222:10.0.0.42:22 bastion.example.com -N -i ~/.ssh/id_ecdsa
ssh -L 8500:localhost:8500 ec2-user@localhost -N -i ~/.ssh/aws.pem -p 2222
解决方案
使用当前版本的 ssh,您应该能够使用:
ssh -L1234:localhost:1234 -J spanky@bastion.example.com ec2-user@consul.internal
来自man ssh
:
-J destination Connect to the target host by first making a ssh connection to the jump host described by destination and then establishing a TCP forwarding to the ultimate destination from there. Multiple jump hops may be specified separated by comma characters. This is a shortcut to specify a ProxyJump configuration directive.
推荐阅读
- html - 引导滑块没有给出预期的结果
- ruby - Ruby 2.5,根据子字符串获取字符串的第一部分
- java - 应为字符串,但在第 3 行第 4 列路径 $.SUCCESS 处为 BEGIN_OBJECT
- python - 如果没有,则查找日期时间列表的最大值
- python - 优化数字的随机化,不包括 Python 中的值列表
- sql - oracle数据库中如何批量更新集
- javascript - 如何有条件地使用暗模式 css 切换基本 css 并在 vuejs 中使用变量?
- verilog - 在 Verilog 中调用模块
- python - 不推荐使用 MATPLOTLIBDATA 环境变量
- next.js - 通过 Url 的路径确定语言