Created
September 15, 2017 18:24
-
-
Save amit/8fed2f136efc33ffd4efa60e2b08efd5 to your computer and use it in GitHub Desktop.
Check SSHD Configuration for Root User Login
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script checks if the root user can access SSH server on this machine | |
FILE="/etc/ssh/sshd_config" | |
if ! [[ -r $FILE ]] | |
then | |
echo "Unable to read $FILE" | |
exit 1 | |
fi | |
# Take one check all lines | |
output=`grep PermitRootLogin $FILE ` | |
# Take two - ignore all comments | |
output=`grep PermitRootLogin $FILE | grep -v '^\s*#' ` | |
# Better alternative is to split the output and analyze second part (awk) | |
if echo $output | grep -i no | |
then | |
echo "PermitRootLogin is set to no! -- GOOD" | |
else | |
echo "Check $FILE for PermitRootLogin. Current setting is $output" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment