8
4

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

AWS入る時スマホ出すのめんどくさいです。

8
Posted at

今回やること

タイトルの通りです。
AWSログインする時にスマホを取り出すのがめんどくさい。
AWSの2段階認証をmacのみで完結させます。
職場で教えて頂いたので備忘録。

AWSのIAMからユーザーを選択。認証情報⇨MFAデバイスの割り当てを選択
スクリーンショット 2022-12-05 16.17.50.png
アカウント名を入力して続行

既にMFAデバイスを割り当てている場合は警告が出るので一度削除して設定し直せばOK。
以下の画面からシークレットキーをコピーかどっか控えておく
image.png

設定手順

brew install oath-toolkit

oathtool --totp --base32 "シークレットキー"
259927 # これそのままMFAコードとして利用できる。


# エイリアス化
# bash使ってるなら
vim ~/.bash_profile
# zshなら
vim ~/.zprofile
#  私はfishなので
vim ~/.config/fish/config.fish

以下のように記述

alias awsotp-hoge='oathtool --totp --base32 "シークレットキー" | pbcopy && pbpaste && echo "ワンタイムパスワードがコピーされました"'

設定し終わったら一旦ターミナル再起動しましょう。

実行

awsotp-hoge
ワンタイムパスワードがコピーされました

これでいつもスマホを見て焦りながら入力していたパスコードがコピーされているので貼り付けるだけです。

clippyとか使ってコマンドを登録しておけば楽チンですね!
リスクヘッジの観点からもスマホとMacで管理できるのは良いかと!

ありがとうございました!

8
4
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
8
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?