0
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 1 year has passed since last update.

Cloud9からSession ManagerでEC2へ接続する

Last updated at Posted at 2022-01-29

Cloud9からAWS Session Managerを使いたくなって試してみたら少々ハマったのでメモ。

■AWS CLI 用の Session Manager プラグインをインストールする

curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/linux_64bit/session-manager-plugin.rpm" -o "session-manager-plugin.rpm"
sudo yum install -y session-manager-plugin.rpm

Session Manager プラグインのインストールを検証

session-manager-plugin

「The Session Manager plugin is installed successfully. Use the AWS CLI to start a session.」となればOK。

■Cloud9からSystems ManagerでEC2に接続に以下のコマンドを実行

aws ssm start-session --target [インスタンスID]
エラー発生
An error occurred (403) when calling the StartSession operation: Server authentication failed: <UnauthorizedRequest xmlns=""><message>Forbidden.</message></UnauthorizedRequest>
Cloud9で一時クレデンシャルを使用していたがこれをやめて、一旦Cloud9のEC2にIAMロール(「AmazonSSMFullAccess」のマネージドポリシーをアタッチした)をアタッチ。

■再度接続

エラー発生
aws ssm start-session --target "[インスタンスID]"

Starting session with SessionId: [インスタンスID]-045c8a0b949a60213
sh-4.2$ 

でけた。

Cloud9のVPCと異なるVPCのEC2へのアクセスもできるし、便利。

一時クレデンシャルの何故だめだったかは調査中。

0
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
0
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?