It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to connect to external server through SSH

How to connect to external server through SSH?

 

My config:

image: node:latest

pipelines:
default:
- parallel:
- step:
script:
- ssh ubuntu@<host-ip-here>
- step:
script: # Modify the commands below to build your repository.
- curl https://google.com # SUCCESS
- step:
script: # Modify the commands below to build your repository.
- curl 172.16.0.14 # ERROR
- step:
script: # Modify the commands below to build your repository.
- curl 172.17.0.1 # ERROR
- step:
script: # Modify the commands below to build your repository.
- curl <host-ip-here> # ERROR
- step:
script: # Modify the commands below to build your repository.
- curl localhost # ERROR
- step:
script: # Modify the commands below to build your repository.
- curl 127.0.0.1 # ERROR
- step:
script: # Modify the commands below to build your repository.
- curl host.docker.internal # ERROR

 

Bitbucket shows that SSH connection is successful, but all of the curl commands failed, excepts google.com

What I'm doing wrong?

1 answer

It looks like you're running the curl commands in the step script but you want to run them on the SSH host.

Have you tried to run the command(s) via SSH instead?

It looks like you're running the curl commands in the step script but you want to run them on the SSH host.

No, it's not how it looks like.

I need to create SSH tunnel to my host for my integration tests in Bitbucket Pipelines, because all databases are there.
Run command with SSH on the remote server is senseless, because I need to check connection of the Docker container to remote server through SSH tunnel.

(docker container)-[SSH tunnel]-(remote server)

I just want to know 2 things:

1. Does Bitbucket Pipelines allow to use docker localhost address (like host.docker.internal), because it's necessary for SSH tunnel.

2. Is it possible with Bitbucket Pipelines to run integration tests which are using databases, having these databases on a remote server?

Ah ok, I now better understand for what you need the SSH connection: tunnel to other remote server(s) not within the pipelines network from within a pipeline step script.

I have no experience with that in Bitbucket Pipelines, but what looks fishy to me in your original parallel step scripts is that only one of those step scripts does open the ssh tunnel. As this is not a service, nor the other steps would reference such a service, this should not be available in the other step scripts.

Additionally please see: How can I use SSH in Bitbucket Pipelines?

----

1. Does Bitbucket Pipelines allow to use docker localhost address (like host.docker.internal), because it's necessary for SSH tunnel.

In the end this depends on the container the step scripts runs in, by default I would assume this does not work out of the box. Have not tested it.

2. Is it possible with Bitbucket Pipelines to run integration tests which are using databases, having these databases on a remote server?

If the remote server is publicly available via the internet, you should get connectivity. I would say this is not ideal to increase the distance to the build system, but as you describe it in your scenario, you need to do it.

It might not be common / easy to setup. See as well: How to use VPN with Bitbucket Pipelines

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

814 views 0 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you