I am setting up automatic deployments with Bitbucket Pipelines and a custom Docker image.
- I have a deployment step in bitbucket-pipelines.yml that runs an SSH command like this (for testing if ssh connection works):
ssh $SSH_USERNAME@$SSH_HOST -p 17177 ls -l /home
- The command results in: Host key verification failed.
- If I run the same command from my pc, with the variables replaced by the exact variables that I have put in as environment variables on bitbucket, the ssh connection and command work
- I have a public key in the bitbucket repo SSH settings
- I have added this public key on the host I am trying to ssh to
- If I manually check the ~/.ssh/authorized_keys file on the host, the public key is indeed there
- What does not work is adding a Known host in the bitbucket SSH Key settings, and I am probably doing something wrong or forgetting something, but I could not find it after long hours of testing stuff. Since I can locally connect to my host via SSH with myusername@am1.fcomet.com I thought the value that I should enter in the 'Host address' field would be 'am1.fcomet.com' but if I click on 'Fetch' I get the error:
'Unable to fetch fingerprints, check host SSH connection and try again'
So I am wrong ? Should I enter something different in the Host address field ?
Or does the problem lies in the fact that I need to ssh to my host over a specific port and is that the reason I cannot add the host address ?
Or should it work even without a Known host normally ?
Did I forget a step somewhere ? Like should I somehow add the public key from bitbucket into my docker image, if so how ? The docker image right now just installs openssh via 'RUN apk add --update openssh' so it knows the 'ssh' command, but it is possible I should also take extra steps in my docker image that I am not aware of.