SSH のセキュリティ強化
パスワードログインを無効化し、キー認証のみ許可
Overview
パスワードログインを無効化し、キー認証のみ許可
Commands
SSH のパスワードログインを無効化します(キー認証のみ)。SSH キーが設定済みであることを確認してください。続行しますか?
sudo sed -i "s/^#\?PasswordAuthentication.*/PasswordAuthentication no/" /etc/ssh/sshd_config
sudo sed -i "s/^#\?PermitRootLogin.*/PermitRootLogin prohibit-password/" /etc/ssh/sshd_config
sudo systemctl restart sshd