The Daily Build

Icon

Software Development, version 3.0

Open an SSH Tunnel in Four Seconds or Less

(This is part four in a series of posts on ssh.)

As I mentioned in a previous post on ssh configuration, your config file can specify a variety settings for each server.

In fact, the Hosts you use don’t even have to exist! (The HostName is the important part.) Consider the following snippet in your ~/.ssh/config.

#
Host work
  HostName localhost
  User myworklogin
  IdentityFile ~/.ssh/id_dsa
  Port 4022
  RSAAuthentication yes
  PubkeyAuthentication yes
  LocalForward 4022 localhost:4022

I’m going to assume remote forwarding is set up and the connection is open from work to cloud as described in this post on remote forwarding; and you’ve got local forwarding set up from home to cloud as described in this post on local port forwarding.

Now you can do “ssh work” from your home pc, and it will automatically log you into your work pc with the right credentials using the tunnel on cloud.example.com. And the scp example above simplifies to “scp work:/tmp/foo.txt ~/foo.txt” — you don’t have to remember the forwarded port numbers.

Typing “ssh work” is nine keystrokes (eight letters plus enter). If you can type 40 wpm, that’s 200 keystrokes per minute, or 3.33 keystrokes per second, which means you can open the tunnel in four seconds!

If you add “alias ssw=’ssh work’” to your ~/.bashrc, you’re down to four keystrokes.

Share and Enjoy:
  • del.icio.us
  • Digg
  • Sphinn
  • Facebook
  • Mixx
  • Google Bookmarks
  • Twitter
  • FriendFeed
  • Posterous
  • email

Related posts:

  1. Use Local SSH Forwarding to Reduce the Number of Manual Hops Local port forwarding is the same as remote port forwarding...
  2. Use SSH to Forward Multiple Protocols to Multiple Machines Let's say you have a half-dozen machines at work you...
  3. How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels Ssh tunneling can be a bit mind bending at first,...
  4. How to Tell SSH Who You Are Do you log in to several servers with different usernames...
  5. Using Python’s ctypes to Call Into C Libraries The ctypes module makes loading and calling into a dynamic...

Category: ssh

Tagged: , , ,

Leave a Reply

Related Posts

Related posts:

  1. Use Local SSH Forwarding to Reduce the Number of Manual Hops Local port forwarding is the same as remote port forwarding...
  2. Use SSH to Forward Multiple Protocols to Multiple Machines Let's say you have a half-dozen machines at work you...
  3. How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels Ssh tunneling can be a bit mind bending at first,...
  4. How to Tell SSH Who You Are Do you log in to several servers with different usernames...
  5. Using Python’s ctypes to Call Into C Libraries The ctypes module makes loading and calling into a dynamic...