Skip to content

Instantly share code, notes, and snippets.

@dewittpe
Created March 19, 2018 20:49
Show Gist options
  • Save dewittpe/071a0274ae8593e1534da9ded2ac6e6c to your computer and use it in GitHub Desktop.
Save dewittpe/071a0274ae8593e1534da9ded2ac6e6c to your computer and use it in GitHub Desktop.
Script to quickly setup ssh keys on remote machines
#!/bin/bash
HOST=git.neptuneinc.org
REMOTEUSER=pdewitt
KEY=/home/$USER/.ssh/id_rsa.pub
ssh -l $REMOTEUSER $HOST mkdir -p .ssh
cat $KEY | ssh -l $REMOTEUSER $HOST 'cat >> .ssh/authorized_keys'
ssh -l $REMOTEUSER $HOST "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment