Thursday, 2 May 2019

Create SSH public/private key

The aim is to be able to connect to (ssh) a remove server without a password.

you@local$ssh-keygen -t rsa -b 4096 -C [your username (e.g. msun]

When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.
Enter your password twice.


Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]

Copy the public key to the remote server


you@local$ cat ~/.ssh/id_rsa.pub | ssh msun@<remove server> 'cat - >> ~/.ssh/authorized_keys'
you@remote's password:

Store your password to the keychain. This ensures you don't need to type password in other terminal session


ssh-add -K ~/.ssh/id_rsa

Reference:

http://mah.everybody.org/docs/ssh#upload-public-key
https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

No comments:

Post a Comment