Skip to content

Instantly share code, notes, and snippets.

@d1rtym0nk3y
Last active December 20, 2015 20:39
Show Gist options
  • Save d1rtym0nk3y/6192227 to your computer and use it in GitHub Desktop.
Save d1rtym0nk3y/6192227 to your computer and use it in GitHub Desktop.
copy your public key to the authorized_keys file on a remote machine
cat ~/.ssh/id_rsa.pub | ssh root@server "(cat > tmp.pubkey ; mkdir -p .ssh ; touch .ssh/authorized_keys ; sed -i.bak -e '/$(awk '{print $NF}' ~/.ssh/id_rsa.pub)/d' .ssh/authorized_keys; cat tmp.pubkey >> .ssh/authorized_keys; rm tmp.pubkey)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment