Skip to content

Instantly share code, notes, and snippets.

@azrsh
Created January 30, 2024 16:10
Show Gist options
  • Save azrsh/91149d024587e1feaf37ebf5913bb3c1 to your computer and use it in GitHub Desktop.
Save azrsh/91149d024587e1feaf37ebf5913bb3c1 to your computer and use it in GitHub Desktop.
Copy public keys registered in GitHub
#!/bin/bash
HOST=$1
curl -sSL "https://github.com/$(gh api user | jq -r '.login').keys" | ssh "${HOST}" 'TEMP=$(mktemp); cat - ~/.ssh/authorized_keys | sort | uniq > ${TEMP}; cat ${TEMP} > ~/.ssh/authorized_keys'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment