Skip to content

Instantly share code, notes, and snippets.

@farrellit
Created January 3, 2018 18:50
Show Gist options
  • Save farrellit/8292cc549cedbce0cb2413cec7d25720 to your computer and use it in GitHub Desktop.
Save farrellit/8292cc549cedbce0cb2413cec7d25720 to your computer and use it in GitHub Desktop.
ip=...
#pubkey=... # default should suffice if you have the default key location
ssh $ip "bash -c 'mkdir -p ~/.ssh; chmod 0700 ~/.ssh; cat > ~/.ssh/authorized_keys'" < ${pubkey:-~/.ssh/id_rsa.pub
@farrellit
Copy link
Author

this overwrites ~/.ssh/authorized_keys with the specified ssh pubkey. It's not idempotent and it's destructive to all other keys in the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment