Skip to content

Instantly share code, notes, and snippets.

@PieterScheffers
Last active December 19, 2015 15:03
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 PieterScheffers/cbde6af6d056b87f65ee to your computer and use it in GitHub Desktop.
Save PieterScheffers/cbde6af6d056b87f65ee to your computer and use it in GitHub Desktop.
SSH Based Authentication
# https://forums.freebsd.org/threads/howto-setting-up-public-key-password-less-ssh-access.1508/
# http://unix.stackexchange.com/questions/42643/ssh-key-based-authentication-known-hosts-vs-authorized-keys
# https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-freebsd-server
# Generate key on client
ssh-keygen -t rsa
# Generate key on server
ssh-keygen -t rsa
# Get public key on client
cat ~/.ssh/id_rsa.pub
# Add to authorized_keys on server
nano ~/.ssh/authorized_keys
# --> paste client public key
# connect from client to server
ssh -p 2222 someuser@somehost
# type 'yes' to accept server and add key to ~/.ssh/known_hosts file
#########################
# Add client public key to authorized_keys file of server
ssh-copy-id -i ~/.ssh/id_rsa.pub -p 2222 someuser@somehost
cat ~/.ssh/id_rsa.pub | ssh -p 2222 someuser@somehost "cat >> ~/.ssh/authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment