Deploy to SFTP Server

What is SFTP?

SFTP is a network protocol that enables secure file transfer. It is based on SSH (Secure Shell). The protocol provides data encryption and authentication, protecting against unauthorized access. The available authentication methods in SFTP protocol include password authentication, SSH key authentication and a combination of SSH key and password, which increases the security.

Deploying files to an SFTP server can be simplified with Buddy CI/CD by automatically updating the server with each push to your repository. In this article, we'll show you how to configure pipelines and optimize deployment to ensure efficient and secure file management.

Example pipeline with deployment to SFTP serverExample pipeline with deployment to SFTP server

Configure pipeline in Buddy

  1. Create a new project in Buddy and select your Git provider.

Creating new projectCreating new project

  1. Add a new pipeline and configure the details: name, trigger mode, and a branch from which you want to deploy.

Adding new pipelineAdding new pipeline

Tip
If you are new to Buddy, check out our quickstart guides that will tell you how to build, test and deploy your type of application.

Configure SFTP deployment

  1. Look up and click SFTP on the action list to add it to the pipeline:

Transfer actionsTransfer actions

  1. The action has five configuration tabs:

Transfer section in SFTP actionTransfer section in SFTP action

  • Transfer – here you define the source path, deployment flags, and files to ignore
  • Target – here you provide the details of the remote server to which you want to upload files
  • Variables – here you can add and modify environment variables required by your workflow
  • Conditions – here you configure the trigger conditions for which the action will run
  • Options – here you define the action's name and behavior on failure and timeout
Warning
If you are using build actions in your pipeline, make sure to select the Filesystem as the source to deploy artifacts and processed files.

In the Target tab, you configure all connection data to the remote server. By default, SFTP operates on port 22.

It is possible to add your own SSH keys or use keys defined in the project or workspace, which facilitates access management and increases configuration flexibility. Read how to correctly use SSH keys

Target tab in SFTP actionTarget tab in SFTP action

Hint
Buddy's deployment is based on changesets. This means only changed files are deployed, which makes it lightning fast ⚡️. The first deployment is always performed from scratch, unless you set a revision on the server in the Options tab.

Sometimes your server may block the SFTP connection from our IPs. In that case, you need to add our IP addresses to the whitelist. You can find the up-to-date list of IPs, divided into the US and EU regions.

In order to upload symlinks via SCP it’s enough to use the recursive mode by adding the -r parameter:

scp -r$

However, enabling the mode will also copy the content to which the symlink points. This is troublesome if we only want the symlinks to be copied, and it’s not possible to do it in a different way with SCP. Usually, this is solved by using rsync and the following command:

rsync -avz -e ssh /scr-dir user@host:/dst-dir$

Unfortunately, this method is very time-consuming. Check how to automate and speed it up with Buddy.

Once you've configured your first deployment, you can expand your knowledge about deployment options in Buddy and learn about 5 ways to deploy PHP apps.

Success
Read how to configure SFTP deploy with YAML and SFTP POST Parameters.
Hint

đź“š Learn more about SFTP action features, integrations and alternatives.

Last update:
Sep 17, 2024