Skip to content

Instantly share code, notes, and snippets.

@AndrewRussellHayes
Last active August 29, 2015 14:09
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 AndrewRussellHayes/1aa2df507c0684292049 to your computer and use it in GitHub Desktop.
Save AndrewRussellHayes/1aa2df507c0684292049 to your computer and use it in GitHub Desktop.
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