Skip to content

Instantly share code, notes, and snippets.

@johndaley-me
Last active November 4, 2015 16:49
Show Gist options
  • Save johndaley-me/7af75f89dcacfb7184fc to your computer and use it in GitHub Desktop.
Save johndaley-me/7af75f89dcacfb7184fc to your computer and use it in GitHub Desktop.
SSH help
# setup passwordless ssh
# on the client machine
# 1. create ssh key pair
ssh-keygen -t rsa -b 4096 -C "[email protected]"
# 2. create authorized_keys file using the PUBLIC key (careful this will destroy an existing authorized_keys file)
scp id_rsa.pub [email protected]:/home/stacy/.ssh/authorized_keys
# Change permissions on .ssh directories and files if needed (on client and server)
cd ~/.ssh
chmod 700 .
chmod 640 authorized_keys
chmod 600 {your_key_files}
# test the connection from the client - should not get password prompt
ssh [email protected]
# Remove password on the server for extra security if you know what you're doing and don't need to sudo
passwd -d stacy
# multiline, multicommand, execute remotely
ssh user@somehost 'export SOME_VAR=someValue\
&& export ANOTHER_VAR=anotherValue\
&& bash -s' < localscript.sh
# list fingerprints
ssh-keygen -l -f ~/.ssh/known_hosts
# list fingerprint of one host
ssh-keygen -l -f ~/.ssh/known_hosts -F myhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment