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.
To complete this tutorial, you will need the following:
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 su
Next, open the NixOS configuration file with a text editor:
nano /etc/nixos/configuration.nix
In 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-unstable
Finally, update the system:
nix-channel --update nixos-unstable
sudo nixos-rebuild switch
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 su
Install the SFTPGo package by running the command below:
nix-env -iA nixos-unstable sftpgo
Restart the NixOS service by running the command below:
sudo systemctl restart nixos.service
After installing SFTPGo, you need to configure it. To configure SFTPGo, follow these steps:
Open the SFTPGo configuration file:
nano /etc/sftpgo/conf.json
In 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 -A
Restart SFTPGo:
sudo systemctl restart sftpgo
Congratulations, you have successfully installed and configured SFTPGo on NixOS Latest.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!