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).
@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
@Alex Tranthat was the problem! Thank you!
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.