30
37

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.

MySQL Workbenchで多段SSHポートフォワードを使ってAWSのRDSに接続する

Last updated at Posted at 2014-02-06

概要

  • WindowsパソコンのMySQL WorkbenchからAWSのRDSに接続したいんだけど、SSH踏み台サーバのはるか彼方にあって、途方に暮れた時に読んでください
  • Puttyのポートフォワードを活用してMySQL WorkbenchからRDSに接続する方法を解説します

構成

図を参照にしてください
構成図.png

方針

  • 防御は強固でどうやっても直接つなぐのはムリ
  • PuttyのSSHポートフォワードで身近な敵のHost:COMGをやっつけます
  • そこから先のAWS軍団(Host: AWSG,DEV)はPuttyでSSHリモートコマンドを発行することでやっつけます

前提

  • 各Hostは全て鍵認証対応、ポートフォワード許可されてるとします
  • Pagentでの鍵認証設定はできてるとします
  • RDSはPort3306で運用しているとします
  • SSHアカウント名はuserとします

手順

Puttyでポートフォワードを許可します

Connection -> SSH -> Authを開き、Allow agent forwardingにチェックをいれます

ポートフォワード設定します

Connection -> SSH -> Tunnelsを開き、 Source Port3306Destinationlocalhost:23306を入力します

Host: COMGで発行するリモートコマンドを設定します

Connection -> SSHを開き、 Remote command欄に下記を記入

Remote_commnad

ssh -A -L 23306:localhost:13306 user@AWSG ssh -A -L 13306:RDS:3306 user@DEV


MySQL Wordbenchの接続先として下記を設定します
> **Connection Method**は **Stndard(TCP/IP)**
> **Hostname**は **127.0.0.1**
> **Port**は **3306**

これで完成!

最終的には下記のようなPortを経由した接続となります。
![構成図2.png](https://qiita-image-store.s3.amazonaws.com/0/32789/bfb1e96c-48e3-3110-881d-4ac0ae2ffdcf.png)

# 仲間募集
[株式会社スピカ](http://spika.co.jp)では一緒に切磋琢磨できるエンジニアの方を募集しています!ぜひ、[こちら](https://www.wantedly.com/companies/spika/projects)をご覧ください!!
30
37
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
30
37

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?