1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

多段SSH Port Forwardingの構成例

Posted at

下図のような構成で、サーバーAからサーバーDのサービスにセキュアにアクセスしたい、という要件を満たすため、多段のSSH Port Forwardingを構成しました。

image.png

前提条件
・サーバーA〜Dの4台がある
・AとDはプライベートNWのみ持つ
・2拠点間にVPNは張らない
・2拠点間に閉域ネットワークも無い

双方ともIBM Cloud環境であればTransit Gatewayでプライベート接続できますが、今回は片方がオンプレミスの想定なので、インターネット経由の接続となります。

サーバーBで、下記のオプションでSSHポートフォワーディングを構成しつつ、サーバーC(169.62.139.xxx)にSSH接続します。(実際は、sshが切れても再接続できるよう、autosshを使いました。また、ログアウトしても維持されるよう、screenで作ったセッション内で実行しています。)

サーバーBのport 20080を、サーバーD(10.208.19.181)のport 80に転送します。
gオプションで、自分以外のサーバー(今回はサーバーA)からも接続できるようになります。

サーバーB
# ssh -M 0 -C -N -g -L 20080:10.208.19.181:80 root@169.62.139.xxx -i ./.ssh/id_key

サーバーCのSecurity Groupは、サーバーBからのSSHが許可されていればOKです。

image.png

サーバーAから、サーバーB(10.193.153.111)の20080にcurlすると、サーバーDで動くウェブサーバーが応答します。

サーバーA
# curl http://10.193.153.111:20080
This is Server D
# 

以上です。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?