Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SSH keygen steps
#make ssh directory
mkdir ~/.ssh
#change mode to 700
chmod 700 ~/.ssh
#Generate new Key
ssh-keygen -b 2048 -t rsa -f [keyname] -P ["password"] # "" for passwordless key.. this is unsafe
#Default Key.
ssh-keygen -b 2048 -t rsa -f id_rsa -P ["password"]
#Add public key to ssh_pubs directory
cp .ssh/*.pub .ssh/ssh_pubs/
#Get Key contents
cat [keyname].pub
#Default Key.
cat id_rsa.pub
#Add Key to ~/.ssh/authorized_keys file
#allow write on keys file
chmod u+w authorized_keys
#add Key
echo id_rsa.pub >> authorized_keys
#when done make read only
chmod u-w authorized_keys
#to force key, use
ssh -i /.ssh/[keyname] user@server.host
#~/.ssh/config SSH Client Configuration
#Add both host names and their identity file:
Host server.host
IdentityFile ~/.ssh/keyname
Host OSXserv.local
IdentityFile ~/.ssh/id_rsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.