Understand, Learn and Implement.. LINUX / UNIX DEVOPS CONTAINERS OPENSHIFT KUBERNETES DEVOPS TOOLS VIRTUALIZATION STORAGE BACKUP SCRIPTS MONITORING MIDDLEWARE

Thursday, August 21, 2014

Linux How To: How To SSH Without Password Authentication

Often you need to remotely run utilities on other machines through unattended batch process or cron job. ssh allows you to execute code on remote machine. However in normal usage it prompts you for password which makes it hard to use in unattended processes. Here is a simple way to eliminate the need for specifying password every time when connecting through ssh.

Let’s assume you want to connect to remote machine named remote as user named user.

You need to first, and only once, generate a private-public keypair using ssh-keygen as follows:

ssh-keygen -t dsa


By default, the home directory will be user home directory and in the pass phrase location just give it as empty(Don't mention any )

This will create a private and public key pair which is stored in ~/.ssh directory.

Next run the following command once for every machine you want to remotely login without specifying password:

scp ~/.ssh/id_dsa.pub user@remote:~user/.ssh/authorized_keys

Now you can login to the machine using ssh without requiring to specify any password. Your public key, which you copied to the remote machine, is checked (not directly) against your private key to verify your authenticity.


0 comments:

Post a Comment