AJ Kovalainen
  • About
  • Blog
April 30, 2009

SSH Login without a Password

(This post is more of a note to self)

Recently, I had to set up an automatic backup of a certain database to be copied over to the backup server over SFTP. I had some problems with authentication when sending within the script, so I followed these simple steps to “automate” the authentication process. Client will have the user connecting to the server. On the client, we generate a key and we tell the server you should trust this key.

Client

  1. Login as the user who will be sending the package
  2. Generate public/private keys
    ssh-keygen -t rsa
  3. This will generate a id_rsa.pub -file in ~/.ssh
  4. Copy it to the server
    scp ~/.ssh/id_rsa.pub user@server:~/.ssh/temp_rsa.pub
  5. Done on the client

Server

This is what you need to do on the server (the target machine)

  1. Login as the user to which the client will be logging into
  2. Add the client’s key to ~/.ssh/authorized_keys 
    cat ~/.ssh/temp_rsa.pub >> ~/.ssh/authorized_keys
  3. Done!

Of course Your Mileage May Vary but that’s basically it!

Written by AJ Kovalainen
Search for the Ovi Store's search New phone: Nokia 5800
  • X x.com/darep
  • GitHub github.com/darep
  • Email ajk@ajk.fi

© AJ Kovalainen

Made with the know-how and the elbow grease