Finally managed to have a system where I can login to my home machine, with a private IP address, from outside. The trick is to create an ssh tunnel to a machine with a global IP address. I did it using this command:
ssh -f -R8008:localhost:22 sajjad@global_machine 'while true;do sleep 100000;done'
This creates a reverse tunnel to ‘global_machine’ so any connections to its 8008 port actually go to port 22 of the private machine. The ‘-f’ puts the command in the background and the last part is an infinite loop which keeps the connection open.
Since port 22 is a privilidged port, this command has to be run as root or you can run the local ssh daemon on a non-priviledged port and use that port in the above command instead of 22.
Now a connection to the home machine can be made with:
ssh -p 8008 localhost
After I got the above part working, the next problem that popped up was that any idle connections were dropped by my ISP, which meant that the connection was also lost after a few minutes.
A quick and dirty fix was to create the tunnel every 15 minutes from cron:
00,15,30,45 * * * * ssh -f -R8008:localhost:22 sajjad@global_machine 'sleep 14m'
This gave me a window to make a connection in, every 15 minutes.
I found the proper fix thanks to Jim and it required a change on the remote server. By default, sshd doesnt send any packets back to the client to keep the connection open. This can be changed by adding this line to sshd_config:
ClientAliveInterval 30
This will send a packet every 30 seconds and prevent the connection from timing out.
In Windows 2000/XP, you must add the variable HOME and set its value to %USERPROFILE% for ssh to work.
Other tech notes:
To get the correct keycode for a keyboard’s keys in X, use ‘xev’.
6th November 2002
To check how well your system is configured against relaying spam, use this command:
telnet relay-test.mail-abuse.org
Exim sometimes fails Test 8, because it appears to accept messages from invalid email addresses. This is explained in the Exim FAQ 0833.
14th November 2002
‘xprop’ will tell you a window’s class and other information useful to a programmer.’xwininfo’ will show basic information such as width, height, depth etc.
Thursday 21st November 2002
This is the howto I used to do the iPaq install:
http://familiar.handhelds.org/releases/v0.6.1/install/install.html.
The GPE distribution for the iPaq only has the US Qwerty and ‘Fitaly’ layouts for the virtual keyboard. I had to edit ‘/usr/share/xkbd/kbdconfig.us’ to get Dvorak.
Wednesday 4th December 2002
Since I will be busy with Eid tomorrow, I will have to let ‘at’ take care of scheduled maintenance.
‘at “17:00 5 Dec 2002″‘ will run whatever command I want tomorrow at 17:00. And I dont even have to be awake.