Skip to Main Content
Wireless Hacks
book

Wireless Hacks

by Rob Flickenger
September 2003
Intermediate to advanced content levelIntermediate to advanced
304 pages
8h 39m
English
O'Reilly Media, Inc.
Content preview from Wireless Hacks

“Turbo-Mode” SSH Logins

Even faster logins from the command line.

If you’ve just come from the previous two hacks, you’ve only seen half of the solution! Even with client keys, you still have to needlessly type SSH server every time you want to SSH in. Back in the dark, insecure, unenlightened days of rsh, there was an obscure feature that I happened to love, which hasn’t (yet) been ported to SSH. It used to be possible to symlink /usr/bin/rsh to a file of the same name as your server. rsh was smart enough to realize that if it wasn’t called as rsh, that it should rsh to whatever name it was called as.

Of course, this is trivial to implement in shell. Create a file called SSH-to with these two lines in it:

 #!/bin/sh
 ssh `basename $0` $*

(Those are backticks around basename $0.) Now put that in your PATH (if ~/bin doesn’t exist or isn’t in your PATH already, it should be) and set up symlinks to all of your favorite servers to it:

 $ cd bin
 $ ln -s ssh-to server1
 $ ln -s ssh-to server2
 $ ln -s ssh-to server3

Now, to SSH to server1 (assuming you’ve copied your public key over as just described), simply type server1 and you’ll magically end up with a shell on server1, without typing ssh, and without entering your password. That $* at the end allows you to run arbitrary commands in a single line (instead of spawning a shell), like this:

 server1 uptime

This will simply show the uptime, number of users, and load average on server1, then exit. Wrap it in a for loop and iterate over a list ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Maximum Wireless Security

Maximum Wireless Security

Cyrus Peikari, Seth Fogie
Real Time Over Wireless

Real Time Over Wireless

Jerome Henry / Rob Barton
Troubleshooting Linux® Firewalls

Troubleshooting Linux® Firewalls

Michael Shinn, Scott Shinn

Publisher Resources

ISBN: 0596005598Catalog PageErrata