Search code examples
sshssh-tunnelcf-bosh

SSH tunnelling through a proxy to run BOSH commands on the remote server


I'm trying to write a non-interactive script which will create a tunnel to a remote machine through a proxy. I have created a tunnel only to a specific port that is: 25555.

ssh -L localhost:25555:$BOSH_TARGET ubuntu@$PROXY -i id_rsa -o StrictHostKeyChecking=no -f -N

I have to use a certificate while targeting the BOSH, which I do.

bosh --ca-cert ca-certificate target localhost:25555

The credentials are taken in the form of environment variables which I have already set.

The target is set but the BOSH target command tries to connect to UAA server which is on a different port that is: 8443 and the connection times out.

I have tried creating a tunnel to 8443 on my localhost, but the BOSH command tries with $BOSH_TARGET:8443 instead of localhost:8443

All these command take place in a docker container. How do I go about this?


Solution

  • This command gets it working, it seems you have to specifically mention --non-interactive.

    bosh --non-interactive ${target_opts} target localhost:25555
    
    printf "${BOSH_USER}\n${BOSH_PASSWORD}" | bosh login
    

    Since non-interactive doesn't work with UAA