This technique relies on a fundamental feature of ssh: port forwarding
There are many variations on this theme, which depend on your desired mail setup. They all require ssh, which is available from http://www.ssh.fi/ and mirrors. RPMs are available at ftp://ftp.replay.com/pub/crypto/ and Debian packages are available at ftp://non-us.debian.org/debian-non-US/ (and their respective mirrors).
To start port forwarding, run the following command:
ssh -C -f popserver -L 11110:popserver:110 sleep 5
Let's take a closer look at that command:
The ssh binary itself, the magic program that does it all.
This enables compression of the datastream. It's optional, but usually useful, especially for dialup users.
Once ssh has done authentication and established port forwarding, fork to background so other programs can be run. Since we're just using the port forwarding features of ssh, we don't need a tty attached to it.
The POP server we're connecting to.
Forward local port 11110 to port 110 on the remote server
popserver. We use a high local port (11110) so any user can create forwardings.
After ssh has forked itself into the background, it runs a command. We use
sleep so that the connection is maintained for enough time for our mail client to setup a connection to the server. 5 seconds is usually sufficient time for this to happen.
You can use most other options to ssh when appropriate. A common setting may be a username, since it might be different on the POP server.
This requires sshd running on the remote server
popserver. However, you do not need to have an active shell account there. The time it takes to print a message ``You cannot telnet here'' is enough to setup a connection.
Once you've figured out the details command to run to establish port forwarding, you can try it. For example:
$ ssh -C -f msingh@popserver -L 11110:popserver:110 sleep 1000
popserver is the ol' POP server. My username on my local machine is
manish so I need to explicitly specify the username
msingh. (If your local and remote usernames are the same the
msingh@ part is unnecessary.
Then it prints:
And I type in my POP password (you may have different shell and POP passwords though, so use your shell one). Now we're done! So we can try:
$ telnet localhost 11110
which should print something like:
QUALCOMM POP v3.33 ready.
Woohoo! It works! The data is sent out over the network encrypted, so the only cleartext is over the loopback interfaces of my local box and the POP server.