How to Install SFTP Server in Linux

Install SFTP Server in Linux

Learn the easy steps to set up an SFTP server on Linux with our comprehensive guide. Securely transfer files over SSH protocol and enhance your data management capabilities. Installing an SFTP server has never been simpler – streamline your file transfers and bolster your Linux system today.

How to Install SFTP Server in Linux

Whenever you install the Linux VM in an On-prem Environment, usually it misses the SFTP server installation which is required to run an SFTP (Secure File Transfer Protocol) server on your Linux system. Let’s dive into a step-by-step guide on installing an SFTP server on Linux, to log in through WinSCP for secure file transfer

Step 1: Choose Your Linux Distribution

Ensure your Linux distribution is equipped with OpenSSH, the package that facilitates secure communication, including SFTP. Most major distributions include OpenSSH by default. To confirm, run the following command:

sudo apt-get install openssh-server # For Debian/Ubuntu
sudo yum install openssh-server # For Red Hat/CentOS

Step 2: Verify OpenSSH Installation

Confirm that OpenSSH is installed and running. Execute the following command:

sudo service ssh status # For Systemd-based systems

Step 3: Configure SSH Server for SFTP

Edit the SSH server configuration file. Use your preferred text editor; for example:

sudo nano /etc/ssh/sshd_config

Ensure the following settings are in place:

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

Save the changes and restart the SSH service:

sudo service ssh restart # For Systemd-based systems

Edit visudo to allow sudo without password to wheel or sudo group


Find and uncomment the below

## Same thing without a password
%wheel ALL=(ALL)       NOPASSWD: ALL

Step 4 [Optional]: Create SFTP-Only Group and User

Create a dedicated group and user for SFTP: (Please replace user name to your desired name and add the home directory path accordingly usually it is /home/username)

sudo groupadd sftp
sudo useradd -g sftp -s /bin/false -m -d /path/to/directory username
sudo passwd username

Step 5: Set Permissions

Ensure proper permissions on the user’s home directory:

sudo chown root:root /path/to/directory
sudo chmod 755 /path/to/directory

Step 6: Test SFTP Connection with WinSCP

Download and install WinSCP on your Windows machine from here. Open WinSCP and configure the session with your Linux server’s IP, username, and password. Choose the SFTP protocol.

For more details on how to use WinSCP with Sudo to edit system files, please check our article

Step 7: Enjoy Secure File Transfers

You’re all set! You can now securely transfer files between your Linux server and Windows machine using the encrypted SFTP protocol through WinSCP.

By following these steps, you’ve established a secure bridge between your Linux server and WinSCP, ensuring encrypted and authenticated file transfers. This setup enhances the integrity and confidentiality of your data, making it an excellent choice for various scenarios, from system administration to secure file sharing.

Scroll to Top