Below is my script.
#!/bin/bash
SERVERS="sl20rht00-t"
#SERVERS="shcbrht01-t"
USR="adm-dt-c"
for host in $SERVERS
do
ssh -tt $USR@$host 'sudo cp /etc/sudoers /Backups/sudoers_11thmarch2015; sudo cp /etc/ssh/sshd_config /Backups/sshd_11thmarch2015; sudo cat /home/adm-dt-c/denyuser >> sudo /etc/ssh/sshd_config; sudo /etc/init.d/sshd restart;'
done
exit 0
The problem is I'm not able to append the line in /etc/ssh/sshd_config
even after the successful execution of the script.
sudo
in randomly like a magic spell - it doesn't work like that. In particularsudo cat /home/adm-dt-c/denyuser >> sudo /etc/ssh/sshd_config
makes no sense. – steeldriver Mar 12 '15 at 13:15