I wrote the script for checking sshd config syntax.
You know the situation very often. You need configure sshd service for some custom or secure things. (root access on sshd or something like that...)
After editing sshd configuration file (the PATH is /etc/ssh/sshd_config) I recommend check the sshd syntax. (the command is sshd -t )
this is a script for checking and restartig service:
#!/bin/bash
#check sshd configuration (-t is test)
sshd -t
# checking exit status...0 = everything is fine, eq - equal
# this condition: when everything is fine, sshd service will be restart and check the status
# when everything is not fine, the system write what is in line 19 (sshd configuration is broken....)
if [ "$?" -eq "0" ]
then
systemctl restart sshd; systemctl status sshd
else
echo "sshd configuration is broken.... do it something! Use magic!"
fi
#I have to sign or sing
echo "Fantomas was there..."
yes of course, script is on github: https://github.com/marsur/ansible_study/blob/main/scripts/sshdt
Žiadne komentáre:
Zverejnenie komentára