add_ssh_key_to_github.sh 344 B

123456789101112
  1. #!/bin/bash
  2. # fail if any commands fails
  3. set -e
  4. # debug log
  5. #set -x
  6. read -rp "Enter Github username: " username
  7. read -rp "Enter Github token: " token
  8. ssh_title=$(awk '{print $3}' < ~/.ssh/id_rsa.pub)
  9. curl -u "${username}:${token}" --data "{\"title\": \"${ssh_title}\", \"key\": \"$(cat ~/.ssh/id_rsa.pub)\"}" https://api.github.com/user/keys