Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Install SSH key via command line?

I'd like to do something like 'ssh-copy-id' to place my SSH public key into bitbucket. I'm using ansible to set up a host, which has several steps that clone bitbucket repositories. Prior to that one needs to install the public SSH key into bitbucket. I'd like to automate this in ansible. Having a way to install the SSH key via the command line for bitbucket would allow this to be automated. Is this possible?

2 answers

0 votes
Pedro Cora Atlassian Team Jun 23, 2014

Hi Tom,

Browsing through the BitBucket API docs, this is not listed as a possible call. I'd say that this is not possible to achieve.

Check https://confluence.atlassian.com/display/BITBUCKET/Use+the+Bitbucket+REST+APIsfor more details.

;)

Thanks for the pointer! I can retrieve my ssh-keys by doing this:

curl -u tekberg https://bitbucket.org/api/1.0/ssh-keys> /tmp/c

In /tmp/c it has a list of dicts with keys "pk", "key" and "label". This way I can see if an ssh-key needs to be added or not.

When I try to add a new ssh-key:

curl -d - -X POST -u tekberg https://bitbucket.org/api/1.0/ssh-keys<<END

key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCgyRWiWhqoyanMeVWO0w522yK7lxVLKTR45u8LJ5R4HwRlVCqqx\

0i9Q/cluoxDES3IlDr06y4c821hl8VCAcLViRG4OE8CFhxX9mHDi3a1n43VzmUOKpZoy/H9V7IW/8f3uOzyRHZ8TU0NiQL9\

tF/EvZCLueFbk5IH/Nb9HpbHmTbdsMXdjAUcczUfNw5/CdZdOXLIlpLpkbGcqVYHZEWOfQmT8La6SCfmAPLKXgSm0sUhjM2\

/ewCGYGjRLt2IveOJiCV0pD4+GtSlTeLm98a2RptClRP4zHYF0CyjLk9r/3/YCvl8LcNyJZApgpWb0qN8tph3MGw8184dNh\

FdpZBz tekberg@apps3"

label: "apps3.labmed.uw.edu"

END

(Note: the key: is all in one line. The label is on the next line.)

I get the following HTML:

<ul class="errorlist"><li>key<ul class="errorlist"><li>This field is required.</li></ul></li></ul>

I think it is saying that the key field is required. Obviously I'm not specifying that field properly. I tried another variation with the keys quoted - "key" and "label" - with the same result.

I think I'm pretty close. Can you tell me how to properly specify the 'key' field?

I would check out

 https://developer.atlassian.com/bitbucket/api/2/reference/resource/users/%7Busername%7D/ssh-keys

for the formatting. Looks like the API now supports this. 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Calling any interview participants for Bitbucket Data Center

Hi everyone,  We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...

515 views 6 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you