Skip to content

Instantly share code, notes, and snippets.

@moeinrahimi
Last active May 23, 2016 19:19
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 moeinrahimi/a3eb1b1d013a0398b15c076430fff895 to your computer and use it in GitHub Desktop.
Save moeinrahimi/a3eb1b1d013a0398b15c076430fff895 to your computer and use it in GitHub Desktop.
Use Public Key Authentication with SSH

#how to generate RSA key to use Public Authentication in SSH

generate rsa-auth key

ssh-keygen

optional : increase security by changing size of the key

  ssh-keygen -b 4096

make this directory if it's not existing already

touch ~/.ssh/authorized_keys; chmod 700 ~/.ssh

copy the content of generated rsa located at .ssh/id_rsa.pub

  nano ~/.ssh/authorized_keys

change the permission of directory

    chmod 600 ~/.ssh/authorized_keys

make sure uncomment the below commands located at /etc/ssh/sshd_config

  • RSAAuthentication yes
  • PubkeyAuthentication yes
  • AuthorizedKeysFile %h/.ssh/authorized_keys

if you're using android device i suggest you use the connectbot app because it support publickey, you should import you rsa key via the app using mange pubkeys -> import -> id_rsa file

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