Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Permission denied (publickey) with my own ssh keys on pipelines

takeno
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 6, 2019

We are using bitbucket pipelines for deployment as we have already done multiple times.

This time we need to use some custom ssh keys instead of self-generated keys, but they doesn't work due `Permission denied (publickey).` error.

 

Current bitbucket-pipeline.yaml:

image: node:11
pipelines:
branches:
master:
- step:
deployment: production
cache:
- node
script:
- cat /opt/atlassian/pipelines/agent/ssh/id_rsa
- ssh root@<ip> sh -c "date"

 

When I use Generate Keys button and I copy-paste public key as authorized_keys on remote server, everything is fine.

When I generate my own keys and I try to use them, the container can't connect to remote server.

 

My procedure:

$ ssh-keygen -f mytest -t rsa -N ''
$ ssh-copy-id root@<ip> -i ./mytest
# local test
$ ssh -i ./mytest root@<ip> sh -c "date"
Tue Aug 6 11:20:32 UTC 2019

 

/opt/atlassian/pipelines/agent/ssh/id_rsa on pipeline contains exactly the same private key I have uploaded and the public key on server is correct.

 

ssh root@<ip> sh -c "date" <1s
+ ssh root@<ip> sh -c "date"Permission denied (publickey).

 

1 answer

1 accepted

0 votes
Answer accepted
Alex Tran
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 11, 2019

@takeno my suspect is you might have to generate the key in PEM format if you are running ssh-keygen on the latest MacOS Mojave (or use ssh-keygen from Linux)

 

ssh-keygen -m PEM -t rsa ...

 

https://serverfault.com/questions/939909/ssh-keygen-does-not-create-rsa-private-key

takeno
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 13, 2019

@Alex Tranthat was the problem! Thank you!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events