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/id_rsa.pub | 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 id_rsa.pub).

Step 2 will then dump the contents of the id_rsa.pub (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.

Posted in IT Tagged with: , , , , ,

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>