Importing SSH keys

Hi,

I'm looking to import SSH keys into Stash (directly into the database) from a different system and ran into a problem. I'm trying to figure out how I should populate the KEY_MD5 column in the database - specifically when I tried to get the hashed value of a key that I added through the UI with md5sum as below, I was unable to produce the same value that Stash had generated itself.

echo 'ssh-rsa ... <email>' | md5sum

I alos tried using MySQL's MD5 function and that did not work either

select MD5('ssh-rsa ... <email>');

Any advice would be appreciated...

2 answers

1 accepted

2 votes
Seb Ruiz Atlassian Team Oct 15, 2012

Hi Rafal,

Why are you inserting SSH keys directly into our database? If you would like to automate/script some processes, you should always be using our REST apis.

Have a look the following question for how to add SSH keys to Stash via REST:

https://answers.atlassian.com/questions/93488/is-there-a-way-to-upload-an-ssh-key-to-stash-via-command-line

Thanks Seb - that helps...

2 votes

Hi,

The safest way of importing SSH keys into Stash is to use the REST endpoint:

POST http://<your-baseurl-here>/rest/ssh/1.0/keys?user=<username>

with body:

{ "text":"<your-public-key-content-here>", "label":"<your-label-here; not used by Stash for auth>"}

Things to watch out for:

  • You'll need Admin permissions to upload keys for other users.
  • Make sure you POST with Content-Type set to "application/json".

Cheers,

Michael

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 06, 2018 in Bitbucket

Do you use Bitbucket Cloud and Jira Cloud? If so, let us know!

Hi Community, I'm Julia and I'm on the Jira Software Cloud marketing team!  We're looking for companies or teams using Bitbucket Cloud and Jira Software Cloud. If your team fits the t...

70 views 2 3
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you