티스토리 뷰

반응형

target_id="userid"

echo -e "$target_id ALL=(ALL)\\tNOPASSWD: /bin/su" >> /etc/sudoers

echo "sed -i -e "/^$target_id/d" /etc/sudoers" | at 18:00 2013-11-15

 

 

유저 찾아서 있으면 2주까지 루트 권한 획득
#!/bin/bash
today=$(date "+%Y-%m-%d")
exdate=$(date -d "+14 days" "+%Y-%m-%d")
read -p "input user id : " userid
echo ==============================================
read -p "input ticket id (ex FI-0000) : " ticketid
bashuser=$(cat /etc/passwd |grep bash |awk 'BEGIN {FS = ":"} {print $1}')

        if echo $bashuser | grep -q -w $userid
                then
                        echo ${userid} account exist!
                        echo -e "$userid ALL=(ALL)\\tNOPASSWD: /bin/su" >> /etc/sudoers.d/$ticketid-$userid-$today
                        echo "remove date & file : $exdate $ticketid-$userid-$today" 
                        echo "rm -f /etc/sudoers.d/$ticketid-$userid-$today" | at 11:59 $today
                else
                        echo $userid account not exist!!
                        echo $userid account not exist!!
                        echo $userid account not exist!!
                        echo $userid account not exist!!
                fi
echo ==============================================
반응형

'linux' 카테고리의 다른 글

rsync copy  (0) 2014.05.28
clientmqueue size  (0) 2014.05.28
scsi 디바이스 rescan  (0) 2014.05.28
linux bonding (본딩)  (0) 2014.05.27
linux hidden patch (loopbask) 데몬방식  (0) 2014.05.27