SSH Key Format in API

Hi, I'm trying to automate adding repository to upsource. I am able to create project but I have problem figuring out key format.

I'm calling https://myupsource/~rpc/testVcsConnection with following POST data

```

{"projectId":"TECH", "vcsSettings": "{ \"mappings\": [ {\"id\":\"puppet2\", \"vcs\":\"git\", \"url\":\"git@git.gitserver.tld:puppet\", \"key\": \"MYKEY\", \"key-passphrase\": \"\" } ] }" }

```

I tried different format of the MYKEY, raw key, base64 etc etc.

I always end with this:

```

{"result":{"status":2,"message":"List remote refs failed: com.jcraft.jsch.JSchException: Error while loading an uploaded key 'the-key': invalid privatekey"}}

```

3 comments
Comment actions Permalink

i have the same problem. And i used the same key on  upsource-2018.2.1154 that worked on a older version  upsource-2017.1.1821.

I looked at the post payload and saw that in 2017 the whitespaces are reflected and in 2018 not. Seems to be the change from HTML Textarea to Textfield is the problem.

I changed the POST request by hand and send it with Postman and it worked.

0
Comment actions Permalink

Hi Christian, 

thx for your reaction.

So what format worked for you ?

For example I have ssh key like this

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDj4q1S64fElS9LiDPW7+5IH8H/feg7G7WnbWtZiDj0Qjq4HRSMOepGj6u2wFr5WHfLUTbGavB4/9tWXZxVAyApLjXSlwV1QqmOWIO+MpLdfzZW0F/0mGbtIkMw0FmIlotdfSJm1nN+RlLvWsYJ/qb9ajcP1xY+9XX7hir2cnyXrIbEBxh7LXFNhB8vR2YvJxQ9a7/tcksjmpwY/UwJYFAn1Bn/5JZ4EuB9guFRqBgYJ/6km3rIBjV0oRuZMzDUJ1bHWIMJckY1+tj9XIAOOFuO/Okjf7WdG4Bp020SjZf+PZt59OOHQW5hF5VaHcoUPs7DujkvCHSl/5PoTCQUxrIj test@test

What should I do with it ?

 

0
Comment actions Permalink

just normal PEM:

-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKC...... 

-----END RSA PRIVATE KEY-----

0

Please sign in to leave a comment.