SSH into machine without password

Being a sys admin I’m constantly logging in and out of machines to perform actions and maintaining a list of passwords, let alone being able to access those passwords for a two second job is a pain in the ass some times.

So to prevent that we can use a secure authentication mechanism to log in without a password without compromising security.

  1. ssh-keygen -t rsa
  2. cat ~/.ssh/ | ssh USER@HOST “mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys”

Step 1 will create a public/private key pair for you and store it in your ~/.ssh/ folder (id_rsa and

Step 2 will then dump the contents of the (your public key) to the destination machine (creating the reciprocal ~/.ssh/ on the destination machine for the user you’re logging in as if it doesn’t already exist) and append the content to the authorized_keys file found there (or create one if the folder is newly created).

This will then prevent the need for you to provide a password when you log in to the destination machine in the future.

Tagged with: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *