SFTP

Setup Steps for SFTP Server with User/Password Credentials

  1. Install SFTP Server if needed: Install an SFTP server on your desired platform. Popular options include OpenSSH (for Linux) and FileZilla Server (for Windows).
  2. Create SFTP User: Create a user account on the server that will be used for SFTP access.

Linux (OpenSSH):

sudo adduser sftpuser  
sudo passwd sftpuser

Windows (FileZilla Server):

  • Open FileZilla Server Interface.
  • Navigate to Edit -> Users.
  • Click Add and enter the username.
  • Set the password for the user.
  1. Configure SFTP Directory and Permissions: Set up the directory structure and permissions for the SFTP user.

Linux (OpenSSH):

sudo mkdir -p /home/sftpuser/uploads  
sudo chown root:root /home/sftpuser  
sudo chmod 755 /home/sftpuser  
sudo chown sftpuser:sftpuser /home/sftpuser/uploads

Configure SFTP Access: Update the SFTP server configuration to restrict the user to SFTP access and to their specific directory.

Linux (OpenSSH):

  • Edit the SSH configuration file:
sudo nano /etc/ssh/sshd_config
  • Add or modify the following lines:
Match User sftpuser  
ChrootDirectory /home/sftpuser  
ForceCommand internal-sftp  
AllowTcpForwarding no
  • Restart the SSH service:
sudo systemctl restart sshd
  1. Configure SFTP Client: Use an SFTP client (e.g., FileZilla, WinSCP) to connect to the SFTP server using the credentials.
  • Host: The IP address or hostname of your SFTP server.
  • Port: 22 (default for SFTP)
  • Username: The username created in step 2.
  • Password: The password set in step 2.
  1. Test connection to the SFTP Server: Use the SFTP client to connect to the SFTP server using the host, port, username, and password provided.