Password-less auto-login with SSH
SSH is widely used with automation scripting, as it makes it possible to remotely execute commands at remote hosts and read their outputs. Usually, SSH is authenticated with username and password, which are prompted during the execution of SSH commands. Providing passwords in automated scripts is impractical, so we need to automate logins. SSH has a feature which SSH allows a session to auto-login. This recipe describes how to create SSH keys for auto-login.
Getting ready
SSH uses an encryption technique called asymmetric keys consisting of two keys–a public key and a private key for automatic authentication. The ssh-keygen
application creates an authentication key pair. To automate the authentication, the public key must be placed on the server (by appending the public key to the ~/.ssh/authorized_keys
file) and the private key file of the pair should be present at the ~/.ssh
directory of the user at the client machine. SSH configuration options (for example...