パスワードによるログインを禁止

SSHなど外部からのアクセスは公開鍵認証のみ許可するため、パスワードによるログインを禁止します。

ちなみに、公開鍵認証を設定しただけでは、公開鍵認証でもログインできるし、これまでどおりパスワードを使ってもログインできる状態になっています。

/etc/ssh/sshd_config を編集します。

$ su

# vi /etc/ssh/sshd_config

次のように書き換えます。

#RSAAuthentication yes
RSAAuthentication yes

#PubkeyAuthentication yes
PubkeyAuthentication yes

#AuthorizedKeyFile .ssh/authorized_keys
AuthorizedKeyFile .ssh/authorized_keys

#RhostsRSAAuthentication no
RhostsRSAAuthentication no

#PasswordAuthentication yes
PasswordAuthentication no

#PermitEmptyPasswords no
PermitEmptyPasswords no

#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

sshdの設定に誤りがないことを確認します。

# /usr/sbin/sshd -t

sshdを再起動して設定を反映します。

# /etc/init.d/sshd restart