How to Install SFTPGo on NixOS Latest
SFTPGo is an open-source FTP server that supports SFTP, FTP, and SCP protocols. In this tutorial, we will guide you through the steps to install SFTPGo on the latest version of NixOS.
Prerequisites
To complete this tutorial, you will need the following:
- A server running NixOS Latest
- A sudo user
Step 1: Add the NixOS Unstable Channel
The latest version of SFTPGo is available in the NixOS Unstable channel. Therefore, you will need to add this channel to your NixOS system. To add the Unstable channel, follow these steps:
Open a terminal and run the following command to become root:
sudo suNext, open the NixOS configuration file with a text editor:
nano /etc/nixos/configuration.nixIn the file, add the following line:
nixpkgs.config.allowUnfree = true;Save and close the file.
Now, update the package list by running the following command:
nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstableFinally, update the system:
nix-channel --update nixos-unstable sudo nixos-rebuild switch
Step 2: Install SFTPGo
With the Unstable channel added to your system, you can now proceed to install SFTPGo. To install SFTPGo, follow these steps:
Open a terminal window and become root:
sudo suInstall the SFTPGo package by running the command below:
nix-env -iA nixos-unstable sftpgoRestart the NixOS service by running the command below:
sudo systemctl restart nixos.service
Step 3: Configure SFTPGo
After installing SFTPGo, you need to configure it. To configure SFTPGo, follow these steps:
Open the SFTPGo configuration file:
nano /etc/sftpgo/conf.jsonIn the configuration file, replace the existing content with the following code:
{ "server": { "listen_address": "0.0.0.0", "listen_port": 22, "log_level": "info", "ssh_host_keys_path": "/etc/ssh", "ssh_host_rsa_key_path": "/etc/ssh/ssh_host_rsa_key", "ssh_host_ecdsa_key_path": "/etc/ssh/ssh_host_ecdsa_key", "data_dir": "/var/lib/sftpgo", "admins": { "sftpgo": { "password": "yourpassword", "home_dir": "/" } }, "user_aliases": [] }, "tls": { "enabled": false }, "sftp": { "enabled": true, "virtual_folders": [] }, "ftp": { "enabled": false }, "scp": { "enabled": false }, "webdav": { "enabled": false }, "hooks": { "on_user_login_success": "", "on_user_login_failure": "", "on_upload_success": "", "on_delete_file": "", "on_delete_directory": "", "on_create_directory": "", "on_rename_file": "", "on_share_file": "", "on_move_file": "", "on_download_file": "" }, "ban": { "history_size": 10000, "history_hours": 72, "max_attempts": 5, "block_seconds": 900, "block_minutes": 5 }, "ratelimit": { "max_requests_per_second": -1, "excluded_ips": [] } }Save and close the file.
Generate the ssh host keys required by SFTPGo:
ssh-keygen -ARestart SFTPGo:
sudo systemctl restart sftpgo
Congratulations, you have successfully installed and configured SFTPGo on NixOS Latest.