新しい機器にsshサーバを設定していたところ、公開鍵認証のみで入れるようにしようとすると、パスワード認証も有効になってしまっていて、パスワードのみでログインできる事象が発生。
簡単に記載すると、今までは、sshd_configの中の以下を有効にしたり、記載したりでよかった
設定例:https://qiita.com/leomaro7/items/b0f0babc3b68dd8be982
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
PermitRootLogin no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
PermitEmptyPasswords no
KbdInteractiveAuthentication no
ChallengeResponseAuthentication no
UsePAM yes
PasswordAuthentication noと記載しても、ダメだったのでなんでだろうと思って、sshd_config.d以下のファイルを確認した所、50-cloud-init.confというファイル内に、
PasswordAuthentication yes
という一文が
ここで、設定を上書きしているようなので、書き換えた。
PasswordAuthentication no
これで、パスワード認証ができないようになりました。
コメント