Tuesday, February 2, 2010

grantaccess.sh

#!/bin/sh

if [ $# -lt 4 ]; then
echo "syntax: $0 host user time 'reason'"
echo "e.g. grantaccess.sh '0am jan 10' 'reason why'"
exit 1
fi

ssh $1 usermod -U $2
ssh $1 chage -E -1 $2
echo "ssh $1 usermod -L $2 " | at $3
echo "ssh $1 skill -KILL -u $2" | at $3
echo `logname` granted $2 access on $1 till $3 - Reason Given:"$4" | mail -s "Access granted"

No comments: