Hey guys,
I've been trying to configure a deployment workflow with bitbucket pipelines using my own SSH Key pair with this pipeline script:
image: atlassian/default-image:2
pipelines:
tags:
release:
- step:
name: Deploy to development
script:
- echo "Deploying to development"
- ssh ec2-user@xx.xxx.xx.xx /home/ec2-user/build.sh param1 param2
Unfortunately, I can not make it work since it gets stuck in the ssh connection returning:
+ ssh ec2-user@xx.xxx.xxx.xx /home/ec2-user/build.sh param1 param2
ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
I'm using my own SSH Key pair which I installed following the next steps:
1) Generate the SSH Key (RSA) without a passphrase;
ssh-keygen -f pipelineAccessKey -t rsa -N ''
2) Set the private key and the public key under Settings > SSH Keys (Pipelines) and fetch the fingerprint
3) Add the public key into ~/.ssh/authorized_keys in the remote server and done.
However when I use SSH keys generated automatically by Bitbucket works but I need using my own SSH Key pair in order to use it in other repositories.
If anyone has any idea what is happening here it would be awesome.
Thanks!
Hi @Yonirt
I would first suggest trying out your generated key pair locally, from within the pipelines docker image, to rule out any issues with the keys or build script.
ssh-keygen -f pipelineAccessKey -t rsa -N ''
chmod 600 pipelineAccessKey pipelineAccessKey.pub
# Ensure you now add the public key to the remote instance authorized keys file.
# Test from a local pipelines build container.
docker run -it -v $(pwd):$(pwd) -w $(pwd) atlassian/default-image:2 bash
# Once inside the running docker container, attempt to ssh to the remote.
ssh -i pipelineAccessKey ec2-user@<host> /home/ec2-user/build.sh param1 param2
I've tested with a newly instantiated t2.micro instance running Amazon Linux (ami-0c3228fd049cdb151) , and was able to connect successfully and execute a script in the ec2-user's home directory.
One possibility could be garbage characters introduced when copy/pasting keys from your machine into the pipelines UI. I would suggest using a tool such as 'pbcopy' (OSX) or 'xclip' (Linux) to copy the contents of the keys to the clipboard before pasting in the key in the pipelines UI to minimise the chance of copy/paste errors. Typical usage would be
cat <keyfile> | pbcopy
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.