Skip to content

Instantly share code, notes, and snippets.

@dapicester
Created July 8, 2015 01:40
Show Gist options
  • Save dapicester/65f83e313dea96b0746e to your computer and use it in GitHub Desktop.
Save dapicester/65f83e313dea96b0746e to your computer and use it in GitHub Desktop.
Copy SSH identity
#!/bin/sh
# Append a key (passed as argument $1) to the ~/.ssh/authorized_keys
# file on a targed host.
DOT_SSH=".ssh"
AUTHORIZED_KEYS="$DOT_SSH/authorized_keys"
if [ ! -e $DOT_SSH ]; then
mkdir $DOT_SSH
chmod 700 $DOT_SSH
fi
if [ ! -e $AUTHORIZED_KEYS ]; then
touch $AUTHORIZED_KEYS
chmod 600 $AUTHORIZED_KEYS
fi
echo $1 >> $AUTHORIZED_KEYS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment