Friday, October 03, 2008

ssh -NfL

Probably at least once in life you've heard the old adage, "It's more powerful on the command line."

But never before have I encountered a command-line argument this powerful. I thought that ssh was powerful, what with its X11 forwarding and secure encryption and all. But just when I thought that the command line had reached its limit, the command line morphed and merged with the full weight of the NFL. Now introducing: ssh -NfL.

ssh, or Secure SHell, is an encrypted way to log into computers remotely, usually through the command line. VNC, or Virtual Network Computing, is another way to log into a computer remotely, but through sharing a screen. VNC with ssh tunneling is a way to combine screen sharing with the security of ssh.

Several websites give helpful hints on how to create ssh tunneling, and for awhile I used a sophisticated solution I found that involves a single line that creates the tunnel, establishes the local connection, and loops a sleep command to auto-close the client. The only problem was that for some reason the connection always seemed slow. I always thought that it was a limitation of my home internet, but one day I noticed that my girlfriend logged into her VNC server from my home with tremendous response rates.

And that day I stumbled upon a new command. A command alone worthy of the heavyweights of Joe Montana and Steve Young. An NFL command.

ssh -NfL creates a fast ssh tunnel with minimal coding. I don't even know if it's technically superior to the more sophistated command I was previously using, but there's no doubt that it's symbolically more powerful with -NfL by its side. What does the NFL do for ssh? "N" is an option not to present a command prompt to the user after logging in, allowing the user to continue operating from the local command line. "f" puts the ssh tunnel into the background, also to free up the local command line. "L" does the dirty work, creating the tunnel by forwarding a local port to the remote server.

And that's it! I did find the commands a little unwieldy to type in by hand on a regular basis, so I wrote up a little script; feel free to use it and comment on how to improve it as well. Now VNC through ssh tunneling is a speedy matter, bringing me from home to work insuperably faster than even the Grey shuttle can.