Documentation / Administrator Guide / Deployment / SFTP Server

SFTP Server

Introduction

SFTP (Secure File Transfer Protocol) is a secure method of transferring files between local and remote servers over SSH. Unlike FTP or FTPS, SFTP encrypts both the command and data, providing an extra layer of security. It is widely used for deploying static sites and other web assets to remote servers.

The SFTP Server deployment method in Staatic allows you to deploy your static WordPress site to any SFTP-enabled server. This method ensures secure transmission of your website’s files, protecting both your data and credentials during the deployment process.

This deployment method supports the following features:

  • Deployment to an SFTP server;
  • Support for SSH key authentication;
  • Ability to set a target directory on the remote server.

Preparation

Before setting up the SFTP deployment method, follow these steps to ensure you’re ready for deployment.

1. Ensure SFTP access

First, ensure you have SFTP access to the target server. This typically requires:

  • The hostname or IP address of the server.
  • A valid username and password or SSH key for authentication.

If you’re unsure about these details, contact your hosting provider or server administrator to ensure SFTP access is enabled.

2. Set up SSH keys (optional)

For enhanced security, we recommend using SSH key-based authentication instead of a password. To set up SSH keys:

  1. Generate a key pair: On your local machine, use ssh-keygen to generate a new SSH key pair if you don’t already have one.
  2. Copy the public key: Provide the server administrator with your public key (id_rsa.pub), or manually upload it to the server under ~/.ssh/authorized_keys.
  3. Secure the private key: Keep the private key (id_rsa) safe. You’ll need it for configuring Staatic’s SFTP deployment.

Note: If you use SSH key-based authentication, you can leave the password field empty during configuration.

Configuration

To configure the SFTP Server deployment method, follow these steps in the WordPress admin interface.

  1. Go to Staatic > Settings > Deployment.
  2. Select SFTP Server from the list of deployment methods.
  3. Enter the following details as described below.

SFTP Server

Host

Enter the hostname or IP address of the SFTP server. This is the server where your static site will be deployed.

Example: sftp.example.com or 192.168.1.1

Port

Enter the port number for the SFTP connection. The default SFTP port is 22, but your server may use a different port.

Example: 22

Target Directory

Specify the path to the directory on the SFTP server where the static version of your WordPress site should be deployed. Ensure this directory exists, or make sure you have permission to create it.

Example: /var/www/my-static-site/

Authentication

You can authenticate with the SFTP server using either a password or SSH key. For better security, we recommend using an SSH key.

Username

Enter the username that you use to log in to the SFTP server. This is required for both password and SSH key authentication.

Password

If you’re using password-based authentication, enter the password associated with the SFTP user account here. If you’re using an SSH key instead, leave this field blank.

SSH Key

To authenticate using an SSH key, upload the private SSH key file here. The public key must already be uploaded to the server for authentication.

Note: If you are not using SSH key authentication, leave this field empty.

SSH Key Password

If your private SSH key is password-protected, enter the passphrase here to unlock the key. This field can be left empty if your key does not require a passphrase.

Network

Timeout

Set the maximum number of seconds to wait for an SFTP command to execute before timing out. This setting can help prevent connection failures due to slow server responses.

Example: 30 (seconds)

Troubleshooting

While deploying via SFTP is generally straightforward, some common issues may arise during the process.

Handling connection issues

If you experience connection failures or timeouts during deployment, consider the following troubleshooting steps:

  1. Check server access: Verify that the hostname, port, and credentials (username, password, or SSH key) are correct. Also, ensure that your IP address isn’t blocked by the server firewall.
  2. Increase timeout: If the deployment is timing out, try increasing the Timeout setting in the configuration. A slow or busy server may require more time to process commands.
  3. Ensure correct SSH key: If you are using SSH key-based authentication, ensure that the correct public key is installed on the server, and the private key is correctly uploaded to the Staatic configuration.
  4. SFTP server logs: Review the logs on your SFTP server for any clues related to authentication failures or file transfer issues.

By following these steps, you should be able to resolve most SFTP-related issues and ensure a successful deployment.