Reputation: 399
I have been writing bash script to clone private Github repo using SSH. Steps need to be followed -
How do I automate step 3 in bash script. Any help would be appreciated.
Upvotes: 1
Views: 2000
Reputation: 1329092
You would need to use the GitHub API POST /user/keys to add a public SSH key to the authenticated user's GitHub account.
It requires that you are authenticated via Basic Auth, or OAuth with at least write:public_key scope.
So your script must take as parameter.
Result: example
# Add a SSH-Key (type "user:passwd ^D"), output: JSON object, or JSON error
curl -X POST -u <user[:passwd]> https://api.github.com/user/keys \
--data "{\"title\": \"<title>\", \"key\": \"$(cat $HOME/.ssh/id_rsa.pub)\"}"
Upvotes: 1