linux_wiki:ssh_pub_priv_keys

This is an old revision of the document!


SSH Pub/Priv Keys

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

From the local client:

1) Create public/private key pair

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/id_rsa.pub = public key (this will go on server)

2) Put public key on remote server(s)

ssh-copy-id -i $HOME/.ssh/id_rsa.pub username@server

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

scp $HOME/.ssh/id_rsa.pub username@server:~/tmp.pub
ssh username@server
cat $HOME/tmp.pub >> .ssh/authorized_keys
rm tmp.pub

3) Ensure ssh-agent is running and add private key passphrase

eval $(ssh-agent)
ssh-add

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

4) Login to server, no password prompt because of ssh-agent/ssh-add

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