Sunday, April 5, 2015

SSH Login Without Password

If there's one place Linux really shines, it's got to be the shell. And the ssh daemon makes it incredibly easy to securely login to a remote computer as if it was your own. You can use ssh to forward ports, as a secure proxy for web browsing, and even for running graphical applications installed on remote machines (see X11 forwarding.) And if you use ssh a lot, removing password based authentication is a serious time-saver.

The first thing you'll need to do to remove password based authentication is to generate your own ssh key on the client machine (the one connecting to the server.) You can do this with the ssh-keygen command. With your key generated, you'll now need to copy your public key to the server's authorized keys list. If you have the openssh-clients package installed, copying your key is as easy as, ssh-copy-id user@server -- where user is your username on the remote machine, and server is the remote machine's IP address or hostname.

You should now be able to login to the remote machine with ssh user@server without entering a password!

(Pro-Tip: If you want to be super-secure, you can disable password based authentication on the remote machine's ssh server by setting PasswordAuthentication to no in  /etc/ssh/sshd_config. Now only users with keys can login!)

No comments:

Post a Comment