SSH Pub/Priv Keys

General Information

Create public/private key pair to login to remote systems with no password prompt.


  • Distro(s): Any

ssh-keygen -t rsa
Enter file to save the key (Enter for default).
Enter password twice to encrypt key pair.

Two files are created:

  • $HOME/.ssh/id_rsa = private key (do not share)
  • $HOME/.ssh/ = public key (this will go on server)
ssh-copy-id -i $HOME/.ssh/ username@server

If ssh-copy-id is not installed, use scp instead

scp $HOME/.ssh/ username@server:~/
ssh username@server
cat $HOME/ >> .ssh/authorized_keys
eval $(ssh-agent)

Enter private key passphrase to add private key to the ssh-agent.

ssh username@server
  • linux_wiki/ssh_pub_priv_keys.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)