Sunday, March 8, 2009

Script to find normal users above UID 500

Script to find normal users above UID 500 and their Shell History. This works in Linux. Other NIXes may require modification.

USERS=`grep ":5*:*:" /etc/passwd | grep "/bin/bash" | awk -F: '{print $1}'`
HOME=`grep ":5*:*:" /etc/passwd | grep "/bin/bash" | awk -F: '{print $6}'`
for i in $USERS
egrep -i "reboot|init|shutdown|halt|poweroff" `grep $i: /etc/passwd | cut -f6 -d:`/.bash_history

Sunday, March 1, 2009

Ever alive SSH session

If you are facing Session timeout issue whenever you are leaving an open session idle for some time you can make use of TCP Keepalive option in putty.

1. Open Putty
2. Go to Connection->Seconds between keepalives(0 to turn off). Give a keepalive value here in seconds, preferably 120 or above.

1. If you are using portaputty you can set it in config file .\putty\sessions\Default%20Settings. Set TCPKeepalives=120.
2. Right inside Linux or any other UNIX we can use /etc/ssh/ssh_config. Set the variable ServerAliveInterval 60.
3. We can use screen command also. ssh host -t screen -xRe^oo.
4. Screen can exist with Putty as well. Go to Connections -> SSH -> Remote command. Then specify screen -xRe^oo

Further Readings