SCP & Rsync¶
win-sshpass is compatible with standard scp and rsync command syntax, with file transfer implemented via SFTP under the hood.
SCP Style Transfer¶
Basic Syntax¶
Upload Files¶
# Upload single file
win-sshpass -p 'pass' scp ./file.txt user@host:/tmp/
# Upload with specific filename
win-sshpass -p 'pass' scp ./file.txt user@host:/tmp/newname.txt
# Upload directory (-r for recursive)
win-sshpass -p 'pass' scp -r ./dist user@host:/var/www/html
Download Files¶
# Download file
win-sshpass -p 'pass' scp user@host:/tmp/file.txt ./
# Download directory
win-sshpass -p 'pass' scp -r user@host:/var/log/nginx ./logs
Specify Port¶
scp uses uppercase -P for port (unlike ssh's lowercase -p):
Supported Options¶
| Option | Description |
|---|---|
-r |
Recursive directory copy |
-P <port> |
Specify port |
-i <key> |
Specify private key |
-q |
Quiet mode |
-C |
Compression (handled by SFTP) |
-v |
Verbose output |
Rsync Style Transfer¶
Basic Syntax¶
Upload¶
Download¶
Specify Port¶
rsync uses --port= for port:
Supported Options¶
| Option | Description |
|---|---|
-a |
Archive mode |
-v |
Verbose output |
-z |
Compress during transfer |
--port=N |
Specify port |
-e ssh |
Specify remote shell (ignored) |
SCP vs Rsync vs SFTP¶
| Method | Syntax | Best For |
|---|---|---|
| SCP | Standard scp syntax | Simple file copy |
| Rsync | Standard rsync syntax | Incremental sync (note: current impl is full transfer) |
| SFTP | -local / -remote flags |
Flexible file transfer, multi-file support |
Note
win-sshpass's rsync implementation uses SFTP under the hood and does not support rsync's incremental sync algorithm. For true incremental sync, install rsync on the remote server and use it directly over SSH.
Next Steps¶
- File Transfer - More SFTP direct transfer usage
- Configuration File - Simplify commands with config files