Skip to content

Instantly share code, notes, and snippets.

@rlan
Last active April 11, 2019 01:33
Show Gist options
  • Save rlan/b4b1e16a8d84f70b8f14456be3226f47 to your computer and use it in GitHub Desktop.
Save rlan/b4b1e16a8d84f70b8f14456be3226f47 to your computer and use it in GitHub Desktop.
Automatic ssh login

How to securely and automaticaly login via ssh without typing password

  1. On the server, e.g. server, create a .ssh folder:
mkdir -p ~/.ssh
  1. On your client, generate a SSH key pair (ie public key, id_rsa.pub, and private key, id_rsa):
ssh-keygen -t rsa

Just hit "ENTER" for the passphrase. This selects the default behavior.

  1. From your client, copy the public key, id_rsa.pub, to the server:
cat ~/.ssh/id_rsa.pub | ssh server 'cat >> ~/.ssh/authorized_keys'

Note: keep your private key, ~/.ssh/id_rsa, PRIVATE !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment