Skip to content

Instantly share code, notes, and snippets.

@JorgeFrancoIbanez
Last active April 1, 2020 17:41
Show Gist options
  • Save JorgeFrancoIbanez/9d6b75ffe6648de4cad32226b29062c1 to your computer and use it in GitHub Desktop.
Save JorgeFrancoIbanez/9d6b75ffe6648de4cad32226b29062c1 to your computer and use it in GitHub Desktop.
#!/bin/bash
for i in $(grep "^[^#;]" /etc/ssh/sshd_config); do
echo $i
for s in ChallengeResponseAuthentication PasswordAuthentication PermitRootLogin X11Forwarding GSSAPIAuthentication;do
echo $s
if [[ $i == "$s"* ]]; then
echo $i;
echo $s;
sed -i "s/$s .*/$s no/g" /etc/ssh/sshd_config;
fi;
done;
done
for i in $(grep "^[#]" /etc/ssh/sshd_config); do
for s in ChallengeResponseAuthentication PasswordAuthentication PermitRootLogin X11Forwarding GSSAPIAuthentication;do
if [[ $i == "#$s"* ]]; then
sed -i "s/#$s .*/$s no/g" /etc/ssh/sshd_config;
fi;
done;
done
sed -i "s/UsePAM .*/UsePAM yes/g" /etc/ssh/sshd_config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment