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

AWSで踏み台を経由したサーバ構築

Last updated at Posted at 2019-06-17

やりたいこと

  • どのサーバへも踏み台サーバを経由すればすぐにログインできるようにしたい
  • 上記にプラスして踏み台サーバを活用してアプリケーションサーバへのログイン経路を限定したい
  • SSHの際も一々IPアドレスで指定しないでパスなしの名前でシュッとログインしたい

↓こんな感じのイメージ
BastionServer.png

インスタンスの作成

細かい手順は省くが、アベイラビリティゾーンは同一に合わせた適当なインスタンスと、
セキュリティグループでSSHを許可したものを作成する。

踏み台サーバ側

  • AWSの管理ページ上で専用のセキュリティグループを作成する
  • どのサーバからでもSSHできる設定にしておく
  • SSH-Keyを作成して秘密鍵を保持(パスフレーズは設定しない)
ssh-keygen
  • ~/.ssh/configに下記の様にアプリケーション側のサーバ情報を書き加えておく
Host <サーバのホスト名>
  HostName <IPアドレス>
  User <ユーザ名>
  Port <SSHポート>
  IdentityFile <秘密鍵の場所>

アプリケーションサーバ側

  • "~/.ssh/authorized_keys"に作成した公開鍵を登録

  • AWSの管理ページ上でセキュリティ設定でグループID指定で踏み台サーバのセキュリティグループからしかアクセス出来ないようにする

これだけで踏み台サーバからしかアクセス出来ないかつ

ssh <.ssh/configで指定したサーバのホスト名>

上記のコマンドでシュッとアプリケーションサーバ側にログインできる

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?