Skip to content

Instantly share code, notes, and snippets.

@pavel-arapov
Last active February 4, 2016 23:18
Show Gist options
  • Select an option

  • Save pavel-arapov/8fd33c87db51cab04494 to your computer and use it in GitHub Desktop.

Select an option

Save pavel-arapov/8fd33c87db51cab04494 to your computer and use it in GitHub Desktop.
Upload public ssh key to remote server
#!/bin/bash
if [ -z "$1" ]; then
echo usage: $0 user@server
exit
fi
echo "uploading key to $1";
cat ~/.ssh/id_rsa.pub | ssh $1 'cat > key.pub && [ -d .ssh ] || mkdir .ssh && [ -d .ssh/autorized_keys2 ] || touch .ssh/autorized_keys2 && cat key.pub >> ~/.ssh/authorized_keys2 && rm key.pub'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment