This tutorial will guide you through the process of installing OpenSSH SFTP server on nixOS Latest.
Make sure you have root access to the nixOS system and have an existing SSH server installed.
To confirm that you have an SSH server installed, run the following command:
systemctl status sshd.service
If you see a message that SSH is not installed, you'll need to install it first before moving on to the next step.
To install OpenSSH SFTP server on nixOS Latest, run the following command:
nix-env -i openssh
Once you've installed OpenSSH SFTP server, you'll need to create a configuration file for it.
Open the SSH configuration file by running the following command:
sudo nano /etc/ssh/sshd_config
Add the following lines to the bottom of the file:
Subsystem sftp internal-sftp
Match Group sftp-users
ChrootDirectory %h
ForceCommand internal-sftp
X11Forwarding no
AllowTcpForwarding no
Save and close the file by pressing Ctrl+X
, then Y
and Enter
.
Note: Make sure you have a group called sftp-users
created. If you don't, create it using the following command:
sudo groupadd sftp-users
To apply the changes made to the SSH configuration file, you will need to restart the OpenSSH server.
sudo systemctl restart sshd.service
By default, only existing system users can use SFTP. To add users to the sftp-users
group, follow these steps:
Create a new user:
sudo useradd -m -G sftp-users <username>
Note: replace <username>
with the actual username of the user you want to create.
Set a password for the user:
sudo passwd <username>
Note: replace <username>
with the actual username of the user you want to create.
Restart the OpenSSH server to apply the changes:
sudo systemctl restart sshd.service
To test if OpenSSH SFTP server is working correctly, you can use an SFTP client like Filezilla
or WinSCP
to connect to your server.
Open your SFTP client and enter the following information:
sftp-users
group you created.Click the connect button to connect to your server.
Once connected, try transferring files to and from your server.
Congratulations! You've installed and configured OpenSSH SFTP server on nixOS Latest. You can now securely transfer files to and from your server using an SFTP client.
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!
Alternatively, for the best virtual desktop, try Shells!