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.
Image loading...Example pipeline with deployment to SFTP server
Configure pipeline in Buddy
- Create a new project in Buddy and select your Git provider.
Image loading...Creating new project
- Add a new pipeline and configure the details: name, trigger mode, and a branch from which you want to deploy.
Image loading...Adding new pipeline
Configure SFTP deployment
- Look up and click SFTP on the action list to add it to the pipeline:
Image loading...Transfer actions
- The action has five configuration tabs:
Image loading...Transfer 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
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
Image loading...Target tab in SFTP action
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.
Deploy symlinks using SFTP
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.
đź“š Learn more about SFTP action features, integrations and alternatives.
Sep 25, 2024