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
<span>Permission denied (publickey).</span><span>+ ssh root@<ip> sh -c "date"</span>