It just does the job and forgive me for not having time to make it better (e.g ..at least putting the pswd in a variable!!!.) ..nah ...Im just too lazy to do it:
###Need sshpass installed , for passing over the password text
#!/bin/sh
SERVERLIST=serverlist.input
RCMD1='uptime'
RCMD2='cat /etc/passwd | grep hacker'
while read SERVERNAME
do
echo "----------------------">>Remote_Exec_report.txt
echo $SERVERNAME>>Remote_Exec_report.txt
sshpass -p 'YourPassword' ssh -o StrictHostKeyChecking=no -n root@$SERVERNAME $RCMD1 >>Remote_Exec_report.txt
echo "------checking hacker user, no output expected-------">>Remote_Exec_report.txt
sshpass -p 'YourPassword' ssh -o StrictHostKeyChecking=no -n root@$SERVERNAME $RCMD2 >>Remote_Exec_report.txt
echo "------Done checking-------">>Remote_Exec_report.txt
done < "$SERVERLIST"
RCMD1='uptime'
RCMD2='cat /etc/passwd | grep hacker'
while read SERVERNAME
do
echo "----------------------">>Remote_Exec_report.txt
echo $SERVERNAME>>Remote_Exec_report.txt
sshpass -p 'YourPassword' ssh -o StrictHostKeyChecking=no -n root@$SERVERNAME $RCMD1 >>Remote_Exec_report.txt
echo "------checking hacker user, no output expected-------">>Remote_Exec_report.txt
sshpass -p 'YourPassword' ssh -o StrictHostKeyChecking=no -n root@$SERVERNAME $RCMD2 >>Remote_Exec_report.txt
echo "------Done checking-------">>Remote_Exec_report.txt
done < "$SERVERLIST"
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.