Setup SFTP in Linux

Steps to Configure SFTP in Linux

  • Configure env vars for Setup

export SFTP_HOME_PATH=/srv/sftpuser
export SFTP_USER_GROUP=sftpgroup
  • Update the apt

sudo apt-get update
sudo apt-get upgrade -y
  • Install OpenSSH

sudo apt install ssh -y
  • Configure sftp

sudo nano /etc/ssh/sshd_config
  • Add the below content at the end of the file (replace vars)

Match Group <SFTP_USER_GROUP>
ChrootDirectory <SFTP_HOME_PATH>
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
PasswordAuthentication yes
PermitRootLogin no
  • Add new group

  • Add user to group and restrict interactive login

  • Set password for sftp user

  • Create directory for sftpuser

  • Set root as own for sftpuser directory

  • Allow group read and execution perms

  • Create Sub Directory for storing data of sftp

  • set sftpuser as owner for Data Directory

  • Connect to sftp

Enter the password you've configured in above steps

Handling Downtime

  • Logging the Failures in SQL Database.

  • Add a timer trigger to retry these failed cases and notify if not worked.

  • Retry for 5 times, and then ignore by logging error.

Last updated