#!/bin/bash # Run this script with "(sudo) bash ". # Exit on error. set -e # This is just a simple echo & a restart. # NOTE: This will not stop passwords (for some users) if another config # drop-in overrides it e.g, match group/users etc. echo "PasswordAuthentication no" > \ /etc/ssh/sshd_config.d/10-PasswordAuthentication.conf systemctl restart sshd