Deploy using SCP

This guide will show you how to deploy your files to a remote host using the SCP-deploy pipe in Bitbucket Pipelines.

For this example we created simple ReactApp and deployed it to production with the SCP-deploy pipe.

A full end-to-end example is available in this repository if you prefer a more hands-on experimentation with deploying to your host using Pipelines and Pipes.


  • Remote host with ssh access

  • Bitbucket repository

Step 1: Configure your Bitbucket repository for the project

Add your credentials and configuration settings in Bitbucket as variables (see: how to configure Pipelines variables).




The user that is configured on the remote host.


The remote host to transfer the files to.

You can define these variables at the deployment environment, repository, or team level.

Step 2: Configure your SSH keys

Set up an SSH key in Bitbucket Pipelines or provide it as a secured variable: SSH_KEY (see using multiple ssh keys). By default, the SCP-deploy pipe will use your configured SSH key and known_hosts file.

Step 3: Configure your server

On your remote host (sometimes called a production node):

  • Allow users to connect on HTTP (port 80).

  • Configure ssh keys to allow access.

Here's a configuration example using NGINX on the server. Note: this configuration is intended for demo purposes only.

1 2 3 4 5 6 7 8 9 10 11 12 13 server { listen 80; listen [::]:80; root /var/www/scp-deploy/html; index index.html index.htm; server_name <your_host_public_DNS_name>, <>; location / { try_files $uri $uri/ =404; } }

Step 4: Setup your CI/CD configuration

Edit your bitbucket-pipelines.yml file. To find out more about the SCP-deploy pipe, select it in the right of the editor.

Add these steps to bitbucket-pipelines.yml :

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 image: node:10.15.3 pipelines: default: - step: name: Build and test caches: - node script: - npm install - npm test - npm run build artifacts: - build/** - step: name: Deploy artifacts using SCP to PROD deployment: production script: - pipe: atlassian/scp-deploy:0.3.3 variables: USER: $USER SERVER: $SERVER REMOTE_PATH: '/var/www/scp-deploy/html' LOCAL_PATH: 'build/*'

This configuration allows you to run tests, build, and deploy your files to the remote host using the SCP-deploy pipe after each push to the Bitbucket repository. Learn more about how to edit and configure your Bitbucket pipelines configuration.

Step 5: Deploy application to production

Push your application’s code to your Bitbucket repository which will trigger the pipeline. You can then select Pipelines  to check pipeline progress. 

Now you can focus on building your great application, everything else is handled with Bitbucket Pipelines.

Last modified on Nov 13, 2020
Cached at 7:24 AM on Jul 28, 2021 |

Additional Help

Ask the Community