Search code examples
sshbitbucketbitbucket-pipelines

Unable to connect from bitbucket pipelines to shared hosting via ssh


What I need to do is to SSH public server (which is shared hosting) and run a script that starts the deployment process.

I followed what's written here:

  • I've created a key pair in Settings > Pipelines > SSH Keys
  • Then I've added the IP address of the remote server
  • Then I've appended the public key to the remote server's ~/.ssh/authorized_keys file

When I try to run this pipeline:

image: img-name
pipelines:
   branches:
      staging:
        - step:
            deployment: Staging
            script:
              - ssh remote_username@remote_ip:port ls -l

I have the following error:

Could not resolve hostname remote_ip:port: Name or service not known

Please help!


Solution

  • The SSH command doesn't take the ip:port syntax. You'll need to use a different format:

    ssh -p port user@remote_ip "command"

    (This assumes that your remote_ip is publicly-accessible, of course.)