Hello,
I'm currently in the process of writing a script to get developers' environment set up. I would like to add ssh authentication to stash in the script, but I'm having some trouble. Is there a way I can add an ssh key to stash via the rest api or some way using curl or wget? I've tried using curl and emulating the request:
curl --user USERNAME:PASSWORD https://STASH_SERVER/plugins/servlet/ssh/keys/add --form "text=MY_SSH_KEY"
But no luck there. I don't have to programatically create a user, as the user already exists in stash at the time someone would run this script.
Thanks!
Yes, you can use our REST interfaces to add keys:
curl -u user:pass -X POST -H "Accept: application/json" -H "Content-Type: application/json" https://stash/rest/ssh/1.0/keys -d '{"text": "contents of public key file"}'
awesome, thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@seb:Thanks a lot for your quick reply,I have tried which you have provided but I am getting the error as:
<p>
CSRF verification failed. Request aborted.
</p>
<p>
Please enable 'Referer' headers for this site and try again.
</p>
Still not able to add SSH key to Bitbucket cloud instance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
An addition to Seb's answer:
If you need to upload SSH keys for other users, you can add the ?user=<username> query parameter. If the 'user' query parameter is not provided, the REST resource defaults to the current user.
Note that you'll need at least Admin permissions to be able to upload SSH keys for other users.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.