Bitbucket Pipeline SCP defaulting to port 22.

Bishal Udash June 20, 2022

Hi, I've recently created a pipeline using atlassian/scp-deploy:1.2.1.

 

This is what I've done so far : 

  • Repository settings > SSH keys > generate keys and placed public key in my servers authorized_keys
  • generated fingerprint using host address as hostip:port

My pipeline is triggered when merging with master branch;

 

pipelines:
branches: #branch specific pipeline definations
master:
- step:
name: Build and Test
image: node:16
caches:
- node
script:
- yarn install
- yarn build
- echo "Build created successfyly"
artifacts:
- build/**
- step: # SCP build folder to server
name: Deployment to dev server
deployment: production
script:
- pipe: atlassian/scp-deploy:1.2.1
variables:
USER: $USER
SERVER: $SERVER
REMOTE_PATH: $REMOTE_PATH
LOCAL_PATH: 'build'
DEBUG: 'true'
EXTRA_ARGS: '-p 22222'
the logs show below error. (i've replaced real ip)
ssh: connect to host 127.0.0.1 port 22: No route to host
lost connection
based on this link, adding  EXTRA_ARGS: '-P 22222' should've solved it but its not in my case.

2 answers

1 accepted

0 votes
Answer accepted
Bishal Udash June 20, 2022

After searching for hours, found a way that works for me. We can pass extra arguments to the scp command to use port 8022, and enable extra debugging as below.

script:
  - pipe: atlassian/scp-deploy:1.2.1
    variables:
      USER: 'ec2-user'
      SERVER: '127.0.0.1'
      REMOTE_PATH: '/var/www/build/'
      LOCAL_PATH: 'build/'
      DEBUG: 'true'
      EXTRA_ARGS: ["-P", "8022"]
0 votes
Bishal Udash June 20, 2022

Yes , i've  tried using the capital letter P and non capital

  • EXTRA_ARGS'-P 22222'
  • EXTRA_ARGS: '-p 22222'

 

pipeline.png

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events