Skip to content

Instantly share code, notes, and snippets.

@rzani
Last active January 19, 2016 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rzani/6ae2423c0b441f10ebf5 to your computer and use it in GitHub Desktop.
Save rzani/6ae2423c0b441f10ebf5 to your computer and use it in GitHub Desktop.
SSH login without password

Create rsa key

user$ ssh-keygen -t rsa

Create .ssh in server target (The directory may already exist, which is fine)

user$ ssh user@server mkdir -p .ssh

Append user's new public key to user@server:.ssh/authorized_keys

user$ cat .ssh/id_rsa.pub | ssh user@server 'cat >> .ssh/authorized_keys'

SSH config

Edit: ~/.ssh/config

Host [regex-host]
 User [user]
 IdentityFile [file.pem]

Send to multiples servers

 for i in {1..5};
 do
  cat ~/.ssh/id_rsa.pub | ssh user@"server$i" 'cat >> ~/.ssh/authorized_keys'
 done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment