1
1

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.

cliで作ったキーペアを使えるようにしてみる

Posted at

出力されたキーペアを使えるように整形してみる
余談ですが、僕はjqを練習する時サンプルを以下のサイトに流して練習しています。

jqPlay

Kye.pem

{
    "KeyMaterial": "RSA PRIVATE KEY", 
    "KeyName": "hogehogeKey", 
    "KeyFingerprint": "nagaimojiretu"
}

秘密鍵として保持したい内容は「KeyMaterial」の値である"RSA PRIVATE KEY"だけ。
秘密鍵の作成をすると上記のやたら長いJSONが標準出力で帰ってくるから整形してテキストフィアイルにリダイレクトしてあげれば使える。

サンプルコマンド
aws ec2 create-key-pair --key-name hogehogeKey | jq -r '.KeyMaterial' >> ./hoge.pem

こんな感じでファイルに出力して[chmod 400]すれば使える。
jq使ったけどこの程度ならフィルターオプションで持ってきた方が良いのかな?

1
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?