Skip to content

Instantly share code, notes, and snippets.

@yyolk
Last active December 14, 2015 02:59
Show Gist options
  • Save yyolk/5017439 to your computer and use it in GitHub Desktop.
Save yyolk/5017439 to your computer and use it in GitHub Desktop.
simple helper for copying my ssh keys to new machines. ((useful if you're trying to deal with 10 pi's and reformat them almost every day))
#!/bin/bash
# simple script to get a ssh-key on a remote machine
# assumes you're using id_rsa as your identity file which is the default from `ssh-keygen`
# usage: ./scpk <[user@]host>
# ie: `./scpk pi@raspberrypi` or `./scpk raspberrypi`
# default to 'raspberrypi' if no host is provided
TARGET_HOST=${1:-"raspberrypi"}
ssh $TARGET_HOST "echo `cat $HOME/.ssh/id_rsa.pub` >> ~/.ssh/authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment