On this page
- What is SFTP and how does it differ from FTP?
- Is the SFTP server already running on my VPS?
- How do I connect and look around?
- How do I upload and download files and folders?
- How do I manage remote files without a shell?
- Can sftp continue a transfer that was cut off?
- How do I automate sftp with a batch file?
- How do I log SFTP activity on the server?
- What do common sftp errors mean?
- Questions
What is SFTP and how does it differ from FTP?
SFTP is a file transfer protocol that runs inside an SSH connection; it is not FTP with encryption added. Logins, file names and contents all travel encrypted over your SSH port, there is no separate data port, and key based authentication works exactly as for a shell login. Plain FTP sends passwords in clear text and needs extra ports opened, which is why it has no place on a public server today.
Because the protocol is standard, graphical clients such as FileZilla, WinSCP and Cyberduck connect with the same address, user and key. This guide uses the command line client, which is already installed with OpenSSH on Linux, macOS and Windows 10 or 11.
Is the SFTP server already running on my VPS?
Yes on every Linux image we offer: the OpenSSH server ships with an SFTP subsystem enabled. You can confirm it in the configuration:
sudo sshd -T | grep -i subsystem
sudo systemctl status ssh # Ubuntu, Debian
sudo systemctl status sshd # Rocky Linux, AlmaLinuxUbuntu and Debian point the subsystem at /usr/lib/openssh/sftp-server, Rocky and AlmaLinux at /usr/libexec/openssh/sftp-server; both are fine. Some setups use internal-sftp instead, which is required when you lock users into a folder, as shown in SFTP-only users in a chroot. If you changed the SSH port, the firewall rule for that port covers SFTP too.
How do I connect and look around?
Open a session the same way you would open SSH; -P (capital) selects a port and -i a key.
sftp deploy@198.51.100.24
sftp -P 2222 -i ~/.ssh/deploy_ed25519 deploy@198.51.100.24
sftp vps # alias from ~/.ssh/configAt the sftp> prompt, commands without a prefix act on the server, and the same command with an l in front acts on your computer:
pwd lpwd
ls -la lls -la
cd /srv lcd ~/Downloads
df -h
helpThat pairing is the one idea to remember. df -h shows free space on the remote file system, and help lists every command your client version supports.
How do I upload and download files and folders?
put sends from local to remote, get fetches from remote to local, and -r handles whole directories. Wildcards work on both.
put site.zip
put -r ./public /var/www/example.net
get /var/log/nginx/access.log
get -r /etc/nginx nginx-copy
mput *.csv
mget reports/2026-*.pdfAdd -p to keep timestamps and modes, for example get -rp /srv/data. A target folder for put -r must exist on the server in older clients; create it first with mkdir if you see an error. Each file shows a progress line with speed and time left. All of that traffic counts toward your monthly transfer allowance, which you can track with the usage guide.
How do I manage remote files without a shell?
The sftp prompt has its own small set of file commands, handy when a user has SFTP access but no shell:
mkdir uploads
rename old.txt new.txt
rm temp.log
rmdir empty-folder
chmod 640 config.php
ln -s /srv/shared current
!ls ~/projectsThe last line runs a local shell command without leaving sftp. There is no remote shell access through sftp, so you cannot run systemctl or edit files in place; for that, log in with SSH as explained in your first SSH session.
Can sftp continue a transfer that was cut off?
Yes. reget and reput (or get -a and put -a) append to a partial file instead of starting over.
reget /srv/iso/debian-13.iso
reput big-dump.sql.zst /home/deploy/big-dump.sql.zstsftp trusts the partial file, so verify the result with a checksum afterwards: sha256sum locally and ssh vps sha256sum /path on the server should print the same value.
How do I automate sftp with a batch file?
Write the commands into a file and pass it with -b. Batch mode needs key authentication (it cannot prompt for a password) and stops at the first failing command unless that command starts with a -.
cat > nightly.sftp <<EOF
cd /srv/exports
-mkdir archive
get -p report.csv /home/deploy/reports/
rename report.csv archive/report.csv
bye
EOF
sftp -b nightly.sftp deploy@198.51.100.24The exit status is 0 only when every command succeeded, so a scheduled job can alert you on failure. Combine it with a timer as described in cron jobs and systemd timers.
How do I log SFTP activity on the server?
Raise the subsystem log level so uploads, downloads and deletions appear in the system journal. Edit /etc/ssh/sshd_config and replace the existing Subsystem sftp line with:
Subsystem sftp internal-sftp -f AUTHPRIV -l INFOsudo sshd -t && sudo systemctl reload ssh # Ubuntu, Debian
sudo sshd -t && sudo systemctl reload sshd # Rocky, AlmaLinux
sudo journalctl -f SYSLOG_FACILITY=10sshd -t checks the syntax first, so a typo cannot stop SSH from reloading. Keep your current session open while you test a new login.
What do common sftp errors mean?
- Received message too long: a shell start-up file prints text. Make
.bashrcquiet for non-interactive sessions. - Permission denied on put: the remote folder belongs to another user.
- Connection closed right after login with a chroot setup: the chroot folder must be owned by root and not writable by the user.
- subsystem request failed: the
Subsystemline points to a path that does not exist; fix it and reload SSH.
Questions about Transfer files with sftp
Do I need an FTP server package such as vsftpd for SFTP?
No. SFTP is served by OpenSSH itself. Installing an FTP daemon adds open ports and clear text logins without any benefit for SFTP users.
Can I give someone SFTP access without a shell?
Yes. Create a user, set ForceCommand internal-sftp in a Match block and optionally a chroot directory. The full recipe is in SFTP-only users.
Which graphical client should I use?
Any client that speaks SFTP works: FileZilla and Cyberduck on all desktop systems, WinSCP on Windows. Choose SFTP as the protocol, enter your server address, port and user, and load your private key.
Is sftp slower than scp?
Modern scp uses the SFTP protocol underneath, so speeds are similar. For many small files, pack them with tar first or use rsync.
How do I quit an sftp session?
Type bye, exit or quit, or press Ctrl+D.