How to deploy to DirectAdmin hosting using SCP ?

Tapan Bhanot
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 23, 2024

Hi,

I'm on directadmin hosting and I'm trying to deploy to the hosting through bitbucket, I've created a pipeline to deploy using SCP, but I get the following error:

 


109 Status: Downloaded newer image for bitbucketpipelines/scp-deploy:1.5.0

110 DEBUG: Starting new HTTPS connection (1): bitbucket.org:443
111 DEBUG: https://bitbucket.org:443 "GET /bitbucketpipelines/official-pipes/raw/master/pipes.prod.json HTTP/1.1" 200 None
112 INFO: Using passed SSH_KEY...
113 Traceback (most recent call last):
114 File "/pipe.py", line 108, in <module>
115 pipe.run()
116 File "/pipe.py", line 74, in run
117 self.setup_ssh_config()
118 File "/pipe.py", line 42, in setup_ssh_config
119 f.write(base64.b64decode(ssh_key).decode())
120 File "/usr/local/lib/python3.10/base64.py", line 87, in b64decode
121 return binascii.a2b_base64(s)
122 binascii.Error: Incorrect padding

 

What I'm doing wrong  ? I'm new to pipelines. Please guide.

 

Thanks in advance.

 

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 25, 2024

Hey @Tapan Bhanot ,

and welcome to the Community!

It looks like you're using the variable SSH_KEY in the pipe to provide the private key to be used when authenticating to the external host, but this key is failing to load as it does not seem to be base64 encoded.

When providing a custom key as the SSH_KEY variable, you should follow the below steps :

  1. Base64 encode the content of the key
  2. Add the key as a secure variable in your repository or workspace. E.g MY_SSH_KEY
  3. Provide the name of the secured variable created on #2 when configuring the SCP deploy pipe : 
    script:
      - pipe: atlassian/scp-deploy:1.5.0
        variables:
          <other variables>
          SSH_KEY: $MY_SSH_KEY # MY_SSH_KEY contains the base64 encoded value of the private ssh  key

Alternatively, you can configure the ssh key directly in Pipelines by navigating to Repository Settings > SSH keys under Pipelines. This key will be used by default by the scp deploy pipe if you don't provide the SSH_KEY variable in its definition.

For more details about the scp deploy pipe and additional examples, the following documentation may also be of help : 

I hope that helps! Let us know in case you have any questions.

Thank you, @Tapan Bhanot !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events