Guide
Copying files from Windows to a Linux server
SFTP and SCP both run over SSH, on the same port 22 with the same keys, and neither needs anything extra on the server. The difference is that one is an interactive shell and the other transfers and exits.
1. Know which one you are using
| Protocol | Port | Encrypted | When to use it |
|---|---|---|---|
| SFTP | 22 | Yes | The default choice. Browse, transfer, delete and chmod in one session |
| SCP | 22 | Yes | One file or directory, short command. Since OpenSSH 9.0 it uses the SFTP protocol underneath |
| FTP | 21 | No | Do not. Credentials and contents travel in the clear |
| rsync | 22 | Yes | Many files, incremental sync, resuming after a drop |
If sshd is running, SFTP is almost always available too, provided Subsystem sftp is not commented out in sshd_config.
2. Interactive transfer with sftp
sftp root@192.168.1.10
sftp -P 2222 root@192.168.1.10
The port flag here is uppercase -P, the opposite of ssh -p. This is the single most common mix-up.
You land at an sftp> prompt with two command sets: no prefix acts on the server, an l prefix acts on the local machine.
| Remote | Local | Does |
|---|---|---|
ls cd pwd | lls lcd lpwd | List, change and print the working directory |
get file | put file | Download or upload a single file |
get -r dir | put -r dir | Transfer a whole directory recursively |
mkdir rm rmdir | lmkdir | Create directories, delete files and directories |
bye to exit | ||
The usual sequence: switch the local side to your build output, switch the remote side to the target directory, then put.
sftp> lcd E:\build
sftp> cd /var/www/app
sftp> put -r dist
3. One-shot transfer with scp
# upload a single file to /opt
scp .\app.tar.gz root@192.168.1.10:/opt/
# upload a whole directory
scp -r .\dist root@192.168.1.10:/var/www/
# download from the server
scp root@192.168.1.10:/var/log/app.log .\
# non-default port
scp -P 2222 .\app.tar.gz root@192.168.1.10:/opt/
A path containing a colon is read as host:path; a local path needs no host prefix. If a Windows path has spaces, quote the whole argument.
4. Uploaded but not working? Check permissions
The file is there, but the site returns 403 or the script will not run. That is usually ownership or mode. Files pushed over scp or sftp inherit your login identity, so a file owned by root is unreadable to www-data.
# hand it to the web user
chown -R www-data:www-data /var/www/app
# directories 755, files 644
find /var/www/app -type d -exec chmod 755 {} \;
find /var/www/app -type f -exec chmod 644 {} \;
# make the script executable
chmod +x /opt/deploy.sh
pwd first. sftp starts in the user's home directory, not the web root, so a put that "vanished" usually landed in /root.5. Two traps worth knowing
Non-ASCII filenames turn into garbage
Windows reads filenames as GBK on a Chinese locale, the server expects UTF-8, and the two do not line up. The command-line sftp has no reliable encoding switch, so the cheapest fix is renaming the file to ASCII before upload. If the name must stay, use a GUI client that handles UTF-8.
A large transfer dies halfway
OpenSSH's sftp cannot resume; a broken transfer starts over. For multi-gigabyte images use rsync instead:
rsync -avz --partial --progress .\big.iso root@192.168.1.10:/data/
--partial keeps the truncated file so the next run continues from there, and -z compresses the stream, which saves real bandwidth on text. Windows has no rsync, so use WSL or a GUI client that resumes.
6. What a dual-pane client adds
If you move a handful of files every day, dragging beats typing. Skiff's SFTP panel sits next to the terminal: local on the left, server on the right, double-click to enter a directory, drag across to start a transfer, with progress and speed in the list. The panel follows the directory you cd into in the terminal, so you do not have to navigate twice.