Skip to content

Instantly share code, notes, and snippets.

@NunoFilipeSantos
Last active May 5, 2018 10:00
Show Gist options
  • Save NunoFilipeSantos/7eee84fcb40b52d5ede6332f902d1b1c to your computer and use it in GitHub Desktop.
Save NunoFilipeSantos/7eee84fcb40b52d5ede6332f902d1b1c to your computer and use it in GitHub Desktop.
Disable root access via SSH
#!/bin/bash
# Disable root access via SSH
# USAGE:
# curl -Lo DisableRootAccessSSH https://gist.githubusercontent.com/NunoFilipeSantos/7eee84fcb40b52d5ede6332f902d1b1c/raw/DisableRootAccessSSH.sh
# chmod +x DisableRootAccessSSH
# ./DisableRootAccessSSH
perl -pi -e 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config
service ssh restart
echo "Root access via SSH disabled!"
# Delete this file after executing
rm -- "$0"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment