Set up a local SFTP server in minutes with SFTPGo

I had to work with SFTP and needed to set up an SFTP server on my Mac for development. It was very difficult to find software to set up an SFTP server on a Mac. Then I found SFTPGo, a very simple solution to SFTP servers.

Github: https://github.com/drakkan/sftpgo

SFTPGo, as the name implies, is an SFTP server written in Go language. It can be run on Linux, macOS and Windows. This blog post will proceed with macOS but everything should be the same on all platforms, except for the installation part.

Installation

Run the below command in a terminal to install SFTPGo using brew on macOS.

brew install sftpgo

Run the below command to start the server. This will create an SQLite database and host keys in the current working directory, and run a web interface on port 8080 and an SFTP server on port 2022. We can configure these settings through a configuration file, but for now let’s just start the server the simplest way.

sftpgo serve

Open http://localhost:8080/web/admin to create an administrator account.

Creating a user

Open http://localhost:8080/web/admin to enter the admin console. In Users page, click Add (+) to create a new user.

Fill in details: a username, a password, a public key (optional if you want to use public key authentication), and a home directory for the user. Click Submit and you are ready to test.

Testing the connection

Run the below command to open an SFTP connection. Of course, replace user with the username you have set in the previous step. This command will open a connection to 127.0.0.1 at port 2022 with user user. It should prompt you to enter a password and establish a successful connection.

sftp -P 2022 [email protected]

Voilà! You have just—hopefully—successfully set up a local SFTP server!

Further configuration

If you want to configure how SFTPGo works, the simplest way is to create a configuration file named as sftpgo with an extension of either JSON or YAML (see the doc for more extensions).

You can configure which public-private key pairs the SFTP server should use as host keys, which port the server should run on, etc.

📮 Have new posts emailed to you


Posted in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.