Deploy using ssh on a bitbucket pipeline

Hey Peeps,

I don’t know if it the right question to ask here. But I will do it anyway.
For my deployment of some of the web applications I have, I have bitbucket.

Now I want to deploy using ssh (connect to the server, do a git pull).
But I am a bit stuck :wave:.

I have added the ssh keys to the pipeline, but I think bitbucket pipeline file is wrong.


image: atlassian/default-image:latest

pipelines:
default:
- step:
deployment: staging
script:
- eval `ssh-agent -s`
- ssh-add ~/.ssh/config 
- ls | ssh kkl@xxxxe.nl -p 4000
- echo "Deploy step finished"

It keeps throwing this error

+ ssh-add ~/.ssh/config
ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory

But when I look at the config file, it exists.
So I have like two questions. How can I connect to my ssh server (fix the error) and how can I run a command after I connected to the ssh server?

Which config file says it exists?

The error seems to point to there being a password on the SSH key btw, which must be typed interactively. If you want to do this kind of thing you need an SSH key without a passphrase IIRC.

As far as running commands over SSH like this, you can pass them to the SSH command:

ssh kll@xxxxe.nl -p 4000 ls -la

If you want to pass complex commands it may be easier to use sh -c for readability:

ssh kll@xxxxe.nl -p 4000 sh -c "cd /path/to/website; git pull"

Thank for your reply.

Its weird, since I have generated the keys using bitbucket itself and import them

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.