【问题标题】:Accessing Jupyter Server Running on EC2 Through Bastion with SSH Tunnel使用 SSH 隧道通过 Bastion 访问在 EC2 上运行的 Jupyter 服务器
【发布时间】:2019-12-29 02:48:55
【问题描述】:

所以我有一个只能通过堡垒访问的 ec2 实例。

ec2 实例在 127.0.0.1:8888/?token=$token 上为我的 jupyter 服务器提供服务

我的目标是运行一个 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 入口,并将堡垒 ssh 密钥添加到 ec2-machine,以便我可以定期从堡垒 ssh 到 ec2)

ssh -f -N -L 8888:127.0.0.1:8888 $user@$ec2_private_ip

【问题讨论】:

    标签: networking amazon-ec2 ssh ssh-tunnel


    【解决方案1】:

    SSH Tunnel through Ubuntu bastion to instance in private subnet 的帮助下解决了这个问题

    命令是:

    ssh -v -N -A -J $user@$bastion_dns -L 8888:localhost:8888 $user@$ec2_private_ip

    【讨论】:

      【解决方案2】:

      当使用-L时,您可以指定接收机器应该将流量发送到哪里。

      假设你有:

      • 本地计算机
      • 堡垒
      • Jupyter 服务器

      因此,您可以运行如下命令:

      ssh -i key.pem -L 8888:jupyter-server:8888 ec2-user@bastion-IP
      

      这会将本地计算机上的localhost:8888 转发到堡垒服务器。

      堡垒服务器随后会将请求转发到 VPC 内的jupyter-server:8888

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-12-13
        • 1970-01-01
        • 2011-11-27
        • 2014-12-15
        • 2010-11-17
        • 2020-06-04
        相关资源
        最近更新 更多