Quick Logins with SSH Client Keys
Use SSH keys instead of password authentication to speed up and automate logins.
When
you’re
an admin on more than a few machines, being able to navigate quickly
to a shell on any given server is critical. Having to type
ssh my.server.com
(followed by a password) is not
only tedious, but it also breaks your concentration. Suddenly having
to shift from “where’s the
problem?” to “getting
there” and then back to
“what’s all this,
then?” has led more than one admin to premature
senility. It promotes the digital equivalent of “Why
did I come into this room, anyway?”
At any rate, more effort spent logging into a machine means less effort spent solving problems. Recent versions of SSH offer a secure alternative to endlessly entering a password: public key exchange.
For these examples, I assume that you’re using OpenSSHv3.4p1 or later. To use public keys with an SSH server, you’ll first need to generate a public/private key pair:
$ ssh-keygen -t rsa
You can also use -t dsa
for DSA keys, or
-t rsa1
if you’re using Protocol
v1. (And shame on you if you are using v1! Upgrade to v2 as soon as
you can!) If at all possible, use
RSA keys—there are some problems with DSA keys, although they
are very rare.
After you enter the command, you should see something like this:
Generating public/private rsa key pair. Enter file in which to save the key (/home/rob/.ssh/id_rsa):
Just press Enter there. It will then ask you for a passphrase; just press Enter twice (but read the ...
Get Network Security Hacks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.