所以我有一个 ec2 实例,我只能通过堡垒访问。
ec2 实例为我的 jupyter 服务器提供服务 127.0.0.1:8888/?token=$token
我的目标是运行一个 ssh 隧道命令,该命令将侦听连接127.0.0.1:8888
,并通过堡垒将它们转发到我的 ec2 实例以127.0.0.1:8888
我试过以下没有运气。
来自当地:
(我可以通过堡垒 ssh 进入堡垒和 ec2 机器而没有问题)
ssh -f -N -L 127.0.0.1:8888:127.0.0.1:8888 -i ~/.ssh/id_rsa $user@$bastion_dns
ssh -f -N -L 8888:127.0.0.1:8888 -i ~/.ssh/id_rsa $user@$bastion_dns
ssh -f -N -L 8888:$ec2_private_ip:8888 -i ~/.ssh/id_rsa $user@$bastion_dns
从堡垒:
(我在堡垒安全组上打开了 8888 入口,并在 ec2-machine 中添加了堡垒 ssh 密钥,以便我可以定期从堡垒 ssh 到 ec2)
ssh -f -N -L 8888:127.0.0.1:8888 $user@$ec2_private_ip
借助此SSH 隧道通过 Ubuntu 堡垒到私有子网中的实例弄清楚了
命令是:
ssh -v -N -A -J $user@$bastion_dns -L 8888:localhost:8888 $user@$ec2_private_ip
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句