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.
- ssh-keygen -t rsa
- 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.

Leave a Reply