Skip to content

Instantly share code, notes, and snippets.

@r10r
Created November 8, 2013 16:23
Show Gist options
  • Save r10r/7373580 to your computer and use it in GitHub Desktop.
Save r10r/7373580 to your computer and use it in GitHub Desktop.
Simple SSH public key deployment.
#!/bin/sh
# Usage: $0 [user@]hostname
public_key_path="$HOME/.ssh/id_dsa.pub"
public_key=$(<${public_key_path})
ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $1 <<-END
echo "Authorize public key ${public_key_path} on \`hostname\`"
[ -d \$HOME/.ssh ] || mkdir \$HOME/.ssh
echo $public_key >> \$HOME/.ssh/authorized_keys
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment