How do you setup ssh to authenticate a user using keys instead of a username / password?
|
For each user: they should generate (on their local machine) their keypair using |
|||
|
I actually prefer ssh-copy-id, a script found on *nix by default (can be put on Mac OS X easily enough as well) that automatically does this for you. From the man page:
|
|||||||||
|
|
Hum, don't get it. Simply create a key and get started. :) HOWTO Additionatly you could forbid login via password. In e.g. /etc/ssh/sshd_config:
|
|||||
|
|
This is fairly straight-forward to do - there's a simple walkthrough to be found here. The main points are:
It's important to remember that this will give anyone who has access to the private key on your machine the same access to the remote machine, so when generating the key pair you may choose to enter a password here for extra security. |
|||||||
|
|
For Windows users to setup putty |
|||
|
|
|
To summarize what others have said, setting up SSH keys is easy and invaluable. On the machine that you will be SSHing from you need to generate your key pair:
Just hit enter where noted and enter a passphrase when prompted - ideally this is different from your regular login password on both the current host and the ones you will be SSHing to. Next, you need to copy the key you just generated to the host that you want to SSH to. Most Linux distributions have a tool
If your distribution doesn't have that, then you should copy the key to the destination host and add it to the (possibly existing)
Finally, to gain the maximum benefit out of SSH keys, you will want to run an SSH agent. If you use a desktop environment (Gnome, KDE, etc.) then just logging out and back in will start an SSH agent for you. If not, you can add the following to your shell RC file (
|
|||
|
|
|
As others have said, your users should make keypairs for themselves on their client machines with ssh-keygen and add their public key to ~/.ssh/authorized_keys on the machine they want to log into. For more detailed information though, I highly recommend SSH, The Secure Shell. |
|||
|
|
|
There is good advice on here, so I won't repeat it. Once you get one server set up to allow you to sign on with keys, you can setup others to do the same with this one liner:
Just cd to your home directory, define the variable remote as one or many server names and do a bunch at once. The password it asks for will be your ssh password for the remote server. You can of course use a simplified version without the for-loop:
REMEMBER: Only copy over your public keys. You don't want your private keys sitting out on some server where anyone with sudo can copy them and brute force your passphrase. |
|||
|
|