Posts Tagged ‘networking’
It’s called a reverse SSH tunnel
And it’s used to keep a link from a device that may be behind a firewall. Or perhaps it’s connected to a highly variable mobile network. When it’s opened, it allows users to “tunnel” through the connection, to wherever the device might be.
Here’s what I put into the shell script “tunnel”, on my iPhone’s ~/mobile directory:
#!/bin/sh
ssh -R 8022:localhost:22 -f -N mpesce@webearth.org
That fairly simple line opens a connection via port 8022 on webearth.org (which sits underneath my telly), to port 22 (which is the normal SSH port) on my iPhone. Thus, if I go to the command line on webearth.org and type the following:
ssh -p 8022 mobile@localhost
Voila, I have a shell into my iPhone.
Yes, those of you who are not serious network geeks, this seems like rocket science. It’s not. Reverse SSH tunnels are used all the time by folks behind, say, the Great Firewall of China, or simply the NSW Public Schools network.
Update: I’ve realized that SSH, as a security precaution, will shut down open connections if they’re not used. In ~/mobile/.ssh, create a new file named config, and put the following line in the file:
ServerAliveInterval 60
That should keep things connected indefinitely.