Skip to content

Instantly share code, notes, and snippets.

@yin
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yin/6011ed38f186b0af9cce to your computer and use it in GitHub Desktop.
Save yin/6011ed38f186b0af9cce to your computer and use it in GitHub Desktop.
# Add a SSH-Key
curl -r POST -u <user[:passwd]> https://bitbucket.org/api/1.0/users/<user>/ssh-keys --data-urlencode "key=$(cat ~/.ssh/id_rsa.pub)" --data-urlencode "label=<label>"
# JSON object, or HTML list of errors
# Get list of current ssh-keys
curl -X GET -u <user[:passwd]> https://bitbucket.org/api/1.0/users/<user>/ssh-keys
# JSON array of objects, attribute 'pk' is <sshkey-id>
# Delete key
curl -X DELETE -u <user[:passwd]> https://bitbucket.org/api/1.0/users/<user>/ssh-keys/<sshkey-id>
# Empty response, or HTML list of arrays, formatted: <ul><li></li>...</ul>
# Get specific SSH-Key details
curl -X GET -u <user[:passwd]> https://bitbucket.org/api/1.0/users/<user>/ssh-keys/<sshkey-id>
# JSON object, or string "Resource not found"
# Add a SSH-Key (type "user:passwd ^D")
xargs curl -X POST -u '{}' https://api.github.com/user/keys --data "{\"title\": \"<title>\", \"key\": \"$(cat $HOME/.ssh/id_rsa.pub)\"}"
# OR
curl -X POST -u <user[:passwd]> https://api.github.com/user/keys --data "{\"title\": \"<title>\", \"key\": \"$(cat $HOME/.ssh/id_rsa.pub)\"}"
# JSON object, or JSON error
# Get list of given user SSH-Keys
curl https://api.github.com/users/<user>/keys
# JSON array of objects, or JSON error
# Get list of current SSH-Keys
curl -X GET -u <user[:passwd]> https://api.github.com/user/keys
# JSON array of objects, or JSON error
# Delete key
curl -X DELETE -u <user[:passwd] https://api.github.com/user/keys/<sshkey-id>
# Empty response 204 No content, or JSON error
# Get specific SSH-Key details
curl -X GET -u <user[:passwd]> https://api.github.com/user/keys/<sshkey-id>
# JSON object, or JSON error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment