こんなの簡単かと思いきや、はまってしまった。
とりあえずこれでOK
#/etc/ssh/sshd_config
PasswordAuthentication no
ChallengeResponseAuthentication no
KbdInteractiveAuthentication no
UsePAM Yes
UsePAM
については、とにかくこうしろと、sshd_config
内に記述がある。
# Set this to 'yes' to enable PAM authentication, account processing, # and session processing. If this is enabled, PAM authentication will # be allowed through the ChallengeResponseAuthentication and # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication via ChallengeResponseAuthentication may bypass # the setting of "PermitRootLogin without-password". # If you just want the PAM account and session checks to run without # PAM authentication, then enable this but set PasswordAuthentication # and ChallengeResponseAuthentication to 'no'.
sshd_config
を変更したらsshdを再起動する必要がある。
参考にしたのはこちら hoge.sub.jp
ちょっと問題があったやり方
PAMを使いたくなかったので、UsePAM no
とPasswordAuthentication no
を設定した。
#/etc/ssh/sshd_config
PasswordAuthentication no
UsePAM no
この設定(UsePAM no
)だとパスワードログインは禁止できるのだが、
パスワードを設定していないユーザーが鍵認証でログインできなくなる。
PAMってなんなのですか。 web.archive.org
2021年12月25日追記
KbdInteractiveAuthentication no
は当初入れていなかったのだが、入れるようにした。
ChallengeResponseAuthentication no
との違いがよくわからないがとりあえず入れておく。
↓の説明を読んでもよくわからない。
www.kunitake.org