How to Set Up SFTP for Secure File Transfer
Introduction
SFTP (SSH File Transfer Protocol) is a secure way to transfer files to and from your server. This guide shows you how to enable and use SFTP on your Linux VPS.
Step-by-step Guide
- Ensure OpenSSH is installed and running
- sudo apt update
- sudo apt install openssh-server
- sudo systemctl start ssh
- sudo systemctl enable ssh
- Check SFTP access (default with SSH)
- SFTP is enabled by default with OpenSSH.
- Test SFTP connection from your local machine:n
- sftp user@your_server_ip
- Replace
userandyour_server_ipwith your actual username and server IP.
- (Optional) Restrict SFTP access to specific users
- Edit the SSH config file:n
- sudo nano /etc/ssh/sshd_config
- Add at the end:n
- Match User sftpusern
- ForceCommand internal-sftp
- PasswordAuthentication yes
- ChrootDirectory /home/sftpuser
- PermitTunnel no
- AllowAgentForwarding no
- AllowTcpForwarding no
- X11Forwarding no
- Match User sftpusern
- Save and exit.
- Edit the SSH config file:n
- Restart SSH to apply changes
- sudo systemctl restart ssh
- Transfer files using SFTP
- From your local machine:n
- sftp user@your_server_ip
- Use commands like
put,get,ls,cd,exitinside the SFTP prompt.
- From your local machine:n
Recommendations
- Always use strong passwords or SSH keys for SFTP users.
- Restrict SFTP access for better security.
- Regularly monitor file transfers and user activity.
Call To Action
eed a secure VPS for your file transfers? Check out our hosting plans! https://xernode.com/#pricing