Thursday, July 30, 2009

ssh tips

most of our servers have timeout for ssh connections or probably the routers or firewalls configured to cut the connections if no data is transferred in either direction after a certain time interval, basically by the time i came back from lunch, all ssh connections will be disconnected. sucks right?

there are 2 ways to prevent this to happen. either do it from the servers or clients side.

1st way: reconfigure sshd on the servers like this:
edit /etc/ssh/sshd_config put ClientAliveInterval 60
and don’t forget to restart sshd on the server;)

2nd way: if you have a bunch lot of servers, i bet you don't want to edit all the servers configs. the easier way is to configure on the client end.

- if your're using linux desktop edit /etc/ssh/ssh_config and add the line:
ServerAliveInterval 60

- if you're using putty - under Connection, put non-zero value for:
Seconds between keepalives (0 to turn off).
eg. 60

- if you're using cygwin edit ~/.ssh/config and add these lines:
Host *
TCPKeepAlive no

ServerAliveInterval 60


or u just can put below options when execute ssh command:
$ ssh -o TCPKeepAlive=no -o ServerAliveInterval=60 servername

so now i can have a longer lunch break huhuhuhuu ;)

oh btw, i've dumped putty + PuTTY Connection Manager, now using cygwin + puttycyg.
with puttycyg, at least u're not stuck with the crap "cmd.exe" windows that comes with cygwin, unless u install Cygwin/X lor. betul dak jep?


1 more thing, ssh to outside world is block from within our company network. here is the trick - reconfigure your sshd to run on port 443. on cygwin install corkscrew, then put these in the ~/.ssh/config
Host outside_server
ProxyCommand corkscrew your_company_proxy_ip 8080 %h 443

$ ssh outside_server
Password:
walla you're now on outside world!

again, if u're using putty - under Connection - Proxy. oh thanks to apai!

p/s: wife aku dok komplen "ape yg awk dok buat ngan screen hitam tu, tak ceria langsung..." eh hitam bukan sebarang hitam ya ;)

3 comments:

Marjan Jeffry said...

betul!!! cmd.exe=crap!!!

tentangseseorang said...

screen hitam tuh la yang dok hack merata. ehehehehe

Unknown said...

aaa xsuka screen hitam ini

sgt alergic

xsuka ssh ni
xsuka putty

tp tu lah keje

tp tatap xsuka
hanya cinta kan eclipse semata2x
cintakan java je

xsuka support.. T___T