24
21

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 5 years have passed since last update.

[攻略済] ssh tunneling を使って 複数の踏み台を攻略するには?

Last updated at Posted at 2014-10-23

下記のような構成の場合どうすればいいのか

client -> 踏み台1 -> 踏み台2 ->DBサーバ

sshだけならtransparent multi-hop sshてなページにあったように、下記の多段sshでDBサーバのmysqlクライアントに接続できた筈(configにProxyCommandを書いた記憶がないが多段環境が手元に無いのでうろ覚え)。

[hoge@localhost] > ssh -A -t 踏み台1 ssh -A -t 踏み台2 ssh -A DBサーバ

解決

推測(以下作業ログ扱い)

多段sshではなくて、sshポートフォワードをしないとworkbenchからは接続方法が多分ないので、参考のMulti-hop ssh tunnel - howto : Creating a SSH tunnel with port forwarding between multiple hostsに従って、下記のようなポートフォワード構成にすればOKの筈。

request
-> 93306:localhost:93306
-> 93306:踏み台1:93306
-> 93306:踏み台2:93306
-> 3306:DBサーバ 

1st tunnel

[hoge@localhost] > ssh -L93306:localhost:93306 fuga@踏み台1

2nd tunnel

[fuga@踏み台1] > ssh -L93306:localhost:93306 piyo@踏み台2

3rd tunnel

[piyo@踏み台2] > ssh -L93306:localhost:3306 poo@DBサーバ

one line

[hoge@localhost] > ssh -v -L93306:localhost:93306 fiuga@踏み台1 -t ssh -v -L93306:localhost:93306 piyo@踏み台2 -t ssh -v -L93306:localhost:3306 poo@DBサーバ

あとはworkbenchからlocalhost:93306 に接続すればいい筈なんだけど・・

参考

24
21
3

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
24
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?