Skip to content

Instantly share code, notes, and snippets.

@mattmccarty
Last active August 14, 2017 00:38
Show Gist options
  • Save mattmccarty/b535e1c5a738107cff709d18e52a3168 to your computer and use it in GitHub Desktop.
Save mattmccarty/b535e1c5a738107cff709d18e52a3168 to your computer and use it in GitHub Desktop.
SSH Without Password
# Locally, Run ssh-keygen.
# When prompted, enter the directory and a unique name for the key to be stored in (i.e: /home/user/.ssh/id_rsa_work)
# When prompted hit enter twice to set an empty password
ssh-keygen
# Locally, Run ssh-copy-id. When prompted enter remote user's password
ssh-copy-id -i ~/.ssh/id_rsa_work.pub remote_user@ip-addr-or-hostname
#
# You should a message similar to the following
# Number of key(s) added: 1
#
# Now try logging into the machine, with: "ssh 'dev@ip-addr-or-hostname'"
# and check to make sure that only the key(s) you wanted were added.
#
#
# You may need to start the ssh agent and then add the private key file
#
eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa_work
# Create/edit the config file (i.e: nano ~/.ssh/config)
nano ~/.ssh/config
# Add the following information
Host ip-addr-or-hostname
HostName ip-addr-or-hostname
IdentityFile ~/.ssh/id_rsa_work
# Save and try to ssh into the remote server without a password
ssh dev@ip-addr-or-hostname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment