Skip to content

Instantly share code, notes, and snippets.

@ericblue
Created September 19, 2016 23:29
Show Gist options
  • Save ericblue/6e973c2791763a903269746d1f59cb8a to your computer and use it in GitHub Desktop.
Save ericblue/6e973c2791763a903269746d1f59cb8a to your computer and use it in GitHub Desktop.
Add new SSH trusted host key
#!/bin/sh
# Deploys new authorized key from id_rsa.pub via SSH so new SSH connections will not require password authentication
# Example: cd ~/user; ./deploy_ssh_key.sh [email protected]
if [ $# -lt 1 ]
then
echo "Usage: $0 <user@hostname>";
exit 1;
fi
echo "Copying id_rsa.pub to $1 authorized keys"
cat ~/.ssh/id_rsa.pub | ssh $1 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment