How to Deploy from GitHub to an SFTP Server Automatically

Devops & Infrastructure, Git, and Tutorials

If you're currently updating your website by dragging files into an SFTP client or SSH-ing into your server to run git pull, there's a faster way. Both methods work, but they're manual — you have to remember to do it every time, and it's easy to miss files or deploy the wrong version.

With DeployHQ, you can connect your GitHub repository to your SSH/SFTP server and have changes deployed automatically every time you push. No manual uploads, no forgotten files, no logging into servers.

This guide walks you through the full setup: connecting GitHub, configuring your SFTP server, running your first deployment, and enabling automatic deployments on push.

What you'll need

  • A GitHub repository with your project code
  • An SSH/SFTP server (a VPS, dedicated server, or shared hosting with SSH access)
  • A DeployHQ account (free plan available — 1 project, up to 10 deploys/day)

Step 1: Create a new project in DeployHQ

After signing up, click the New Project button at the top of the screen.

New project

Enter a name for your project and choose GitHub as the repository provider. DeployHQ also supports Bitbucket, GitLab, and manual repository configuration.

Step 2: Connect your GitHub repository

Once you click Create Project, you'll be prompted to log in to GitHub and authorize DeployHQ. After that, you'll see a list of repositories you have access to.

Repository list

Select your repository. DeployHQ will automatically add an SSH public key to access it. Keep the add a webhook option checked — this is what enables automatic deployments later.

Step 3: Configure your SSH/SFTP server

After connecting your repository, you'll be directed to the New Server screen. Enter a name for your server, then choose SSH/SFTP as the protocol.

Enter your server details:

  • Hostname: Your server's IP address or domain name
  • Username: The SSH user (e.g., deployhq, www-data, or your hosting username)
  • Authentication: Choose SSH key (recommended) or password

SSH/SFTP details

If you choose SSH key authentication, DeployHQ generates a unique public key for your project. Copy it and add it to ~/.ssh/authorized_keys on your server. Make sure the permissions are correct:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Tip: If you run into authentication issues, see our guide to debugging SSH connections or the server troubleshooting guide.

Set the deployment path to the directory where your files should go (e.g., /var/www/html or public_html). If you leave it blank, files will be deployed to the user's home directory.

Click Create Server to finish.

Step 4: Run your first deployment

With your repository and server configured, click Deploy for the first time in the top right of your project.

First deployment

Review the details — the server and branch are selected automatically. The start revision shows The very first commit (since nothing has been deployed yet), and the end revision is the latest commit on your branch.

Click Deploy. DeployHQ will transfer all files to your server.

First deployment complete

Once complete, you can review the deployment log to see exactly which files were transferred.

Step 5: Enable automatic deployments

This is where the real time savings come in. Go to the Automatic Deployments page in the left sidebar and enable it for your server:

Auto deployment

Now, every time you git push to GitHub, DeployHQ will automatically detect the new commits and deploy only the changed files to your server. No manual intervention needed.

After pushing a test commit, you can see the automatic deployment in action:

New deployment

The deployment log shows which files were uploaded and confirms it was triggered automatically. On your server, the changes are live:

-rw-rw-r-- 1 deployhq deployhq    0 Mar 21 15:56 testfile
-rw-rw-r-- 1 deployhq deployhq    0 Mar 21 15:56 testfile2

That's it — you've replaced manual SFTP uploads with automatic, git-triggered deployments.

What else can DeployHQ do?

Once you have basic deployments working, there are several features that can streamline your workflow further:

  • Build pipelines: Compile Sass, TypeScript, or run npm build before deploying — no need to commit compiled assets to Git
  • SSH commands: Run commands on your server after deployment (restart services, clear caches, run migrations)
  • Excluded files: Prevent specific files from being uploaded (e.g., .env, node_modules)
  • Config files: Manage server-specific configuration files outside your repository
  • Deploy to multiple servers: Push to staging and production from different branches

If you have any questions, drop us an email at support@deployhq.com or find us on Twitter/X.