Skip to content

Instantly share code, notes, and snippets.

@JorgeFrancoIbanez
Last active August 6, 2019 16:34
Show Gist options
  • Save JorgeFrancoIbanez/f35e41cb8fdca40d752ac3f0f0d5a1eb to your computer and use it in GitHub Desktop.
Save JorgeFrancoIbanez/f35e41cb8fdca40d752ac3f0f0d5a1eb to your computer and use it in GitHub Desktop.
SSH KEY cOnfuiguration for only ssh access
#!/bin/bash
for i in $(grep "^[^#;]" /etc/ssh/sshd_config); do
echo $i
for s in ChallengeResponseAuthentication PasswordAuthentication PermitRootLogin X11Forwarding;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;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