Skip to content

Instantly share code, notes, and snippets.

@h1romas4
Last active June 19, 2020 09:30
Show Gist options
  • Save h1romas4/8607a59e497de7c268041d60aab51ab5 to your computer and use it in GitHub Desktop.
Save h1romas4/8607a59e497de7c268041d60aab51ab5 to your computer and use it in GitHub Desktop.
fumidai-host 経由で target-host に接続し、target-host 内でポートフォワードする ssh コマンド
# node.js の debug ポート(9229)接続の例
# ↓ssh元(PC) ↓target-hostからみたlocalhost
ssh -t -L 19229:localhost:44444 fumidai-host ssh -i .ssh/target-host.pem -L 44444:localhost:9229 target-host
# - 前提として ssh 元(PC) から fumidai-host に ssh 接続できるように .ssh/config などを定義すること。
# - target-host には fumidai-host はからの ssh(22) のみしか接続できない場合を想定。
# - ssh 元(PC) に 19229 ポートで接続を起動する(デバッガの接続先設定は localhost:19229)
# - 上記コマンドを叩いて target-host にログインできればOK(ターミナルはそのままにすること)
# - fumidai-host に target-host の ssh(22) の接続に使う秘密鍵が配置されていること(.ssh/target-host.pem)
# - target-host 内で自分(localhost)宛てにポートフォワードしている 44444:localhost:9229 target-host
# - ポート番号 44444 は任意のものでかまわないが、ssh 元(PC) と fumidai-host ともに使われていないこと。
# - 特に fumidai-host を多人数で使う場合は注意。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment