Logo

How to Setup SFTP Server on Fedora 40

Mar 23, 2024

To set up an SFTP server on Fedora 40, you need to configure SSH to allow SFTP connections.

Step 1 : Ensure that the sshd service is installed and running:

sudo systemctl status sshd

Step 2 : Edit the sshd configuration file to allow SFTP:

sudo nano /etc/ssh/sshd_config

Add or uncomment the following line:

Subsystem sftp internal-sftp

Match Group sftp
        ChrootDirectory %h
        X11Forwarding no
        AllowTcpForwarding no
        ForceCommand internal-sftp

Step 3 : Restart sshd

sudo systemctl restart sshd

Step 4 : Create an SFTP group

sudo groupadd sftp

Step 5 : Create an SFTP user

sudo adduser sftp_user

Step 6 : Set a password for the SFTP user

sudo passwd sftp_user

Step 7 : Assign the user to the SFTP group

sudo usermod -aG sftp sftp_user

Step 8 : Set the appropriate permissions for the directories users will access via SFTP.

sudo chown root:root /home/sftp_user
sudo chmod 755 /home/sftp_user
sudo mkdir /home/sftp_user/upload
sudo chown sftp_user:sftp_user /home/sftp_user/upload
sudo chmod 755 /home/sftp_user/upload

Step 9 : Restart SSH service

sudo systemctl restart sshd

Step 10 : Test the connection

- Open an SFTP client (e.g., FileZilla).

- Add a new site

  • Enter the "Host" (IP address or domain name).
  • Select "SFTP - SSH File Transfer Protocol".
  • Set "Port" to 22.
  • Choose "Normal" login type, and enter the username and password.

- Click "Connect".

Congratulations! You have successfully set up an SFTP server on Fedora 40.

Recommended