PuTTY SSH Keep Alive with AutoHotKey

If you are having trouble with PuTTY getting disconnected after being idle, usually being kicked by a router, try running this script with AutoHotKey:

; Optional – auto login script

run, …\putty.exe -load putty_profile , , , newpid
winwait, ahk_pid %newpid%
Send xxx.xxx.xxx.xxx{enter} ; put your IP here
sleep, 1500
ControlSend, , username{enter}, ahk_pid %newpid%
sleep, 500
ControlSend, , password{enter}, ahk_pid %newpid%

; KEEP ALIVE SCRIPT:
; %newpid% will refer to the original putty window, we need to refind the
; new shell window, which we do via ahk_class PuTTY
loop
{
sleep 60000
IfWinExist ahk_class PuTTY
{
IfWinNotActive ahk_class PuTTY
{
ControlSend , , date{enter}, ahk_class PuTTY
}
}
else
{
break
}
}

2 thoughts on “PuTTY SSH Keep Alive with AutoHotKey

  1. Pingback: bachelor of arts in psychology

  2. Pingback: Free Scan to PDF

Leave a Reply