Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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?

2 answers

1 accepted

I found the solution:

script:      
- ssh -fN user@<server-ip> -L *:1234:localhost:1234 # opening SSH tunnel to the authorization service

- npm run test-integration -- --config config-bitbucket-pipeline.json

As connection address in the test script itself I use http://localhost:1234

 

p.s. This Bitbucket community is so helpful, OMG! 😂

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

I need SSH connection to obtain authorization token from external service for integration testing inside pipelines.

Suggest an answer

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

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

428 views 10 8
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