LoginSignup
0
1

More than 3 years have passed since last update.

google-authenticator に認証コードの再入力までの猶予期間を設定する

Posted at

背景

google-authenticator を使って二段階認証を実施していると、毎回認証コードを聞かれるのが面倒くさい。
特に複数台にデプロイする時とか30秒待たないといけないのでツライ。
どうやら、1.06で猶予期間の設定ができるようにオプションが追加されたらしいのでアップデートして試して見る。

環境とか前提

  • Amazon Linux 2
  • epel を有効にし、google-authenticator@1.04 をインストールおよび設定済み

EPELのアップデート

確認してみると、epel7 では 1.04 までしか提供されていなかったので、epel8 にアップデートしておく。

/etc/yum.repos.d/epel.repo を編集

$release とか 7 と記載されている箇所を 8 に変更する。


baseurl=http://download.fedoraproject.org/pub/epel/8/$basearch
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8

GPG-KEY を取得しておく

sudo wget https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8 -P /etc/pki/rpm-gpg/

google-authenticator をアップデートする

パッケージのアップデート

sudo yum update google-authenticator

猶予期間を設定し反映する

google-authenticator モジュールの設定を行っている /etc/pam.d 配下のファイルを編集する。

下記の様にモジュールの設定箇所に grace_period=3600 オプションを指定する(指定値は秒数)。

auth        sufficient    pam_google_authenticator.so nullok echo_verification_code grace_period=3600

変更を反映する

sudo systemctl restart sshd

あとは、二段階認証を有効にしているユーザーにて接続の確認を行って問題なければOK。

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