Thu, 25 Oct 2007

« Video editing in emacs | MAIN | Word counts »

ssh without a password

Sometimes you need to be able to ssh to a server without giving it a password; say, if you have an automated process that writes files and copies them to a server. I had to set this up quite a few times recently - here's the recipe I followed (this assumes that the permissions on your various ~/.ssh directories are correct)

You'll need:

  • a client: a computer from which you'll ssh to another
  • a server: the computer to which you'll ssh from a client

Then,

  • on the client, run 'ssh-keygen -t rsa' to generate ~/.ssh/id_rsa.pub and associated files. When asked for a password, just hit Enter. You need to generate id_rsa.pub only once per client - you can reuse it for each of the servers.
  • scp ~/.ssh/id_rsa.pub server:~/.ssh/client.pub
  • ssh server
  • supply your password to get in
  • cd ~/.ssh
  • cat client.pub >> authorized_keys
  • if this creates a new authorized_keys file, change its permissions to 600: chmod 600 authorized_keys
  • log out of the server & try to ssh to it - you should get in without having to specify a password
  • of course this is less secure than ssh with a password, so use it wisely and sparingly
  • your mileage may vary - some installations may require a file named authorized_keys2; the above recipe works for me in my environment.

A facility for quotation covers the absence of original thought.—Lord Peter Wimsey

Left column Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.