Is there a way to identify with a username and password to github.com servers for the purpose of adding an ssh key to the github user account? So far everything I've read suggests that a user's ssh key must be added via the web GUI. I'm looking for the method or process of adding a key via a command line interface or else a bash/ansible/something script.
|
Auth with username and password is supported by github api:
So just choose a lib in the language you prefer and use the implemented version of the Create a Public Key "Public Key" API Section:
INPUT
If you want to use it from command line (via curl):
or even without prompting for password:
here is a nice little tutorial for using curl to interact with github API |
|||||
|
Similar to xx4h's answer, this is how I do it in scripts for automating new VM setups.
It gives you a new SSH key, includes it in the curl call and gives a unique but still easily identifiable name for each one on the GitHub side (e.g. running now would give DevVm_150602142247). |
|||
|
Another option is to use an API token... I use the following on our internal gitLab server snippet:
|
|||
|
|
|||
|