SFTP Uploader
A high-performance CLI tool for uploading folders to SFTP servers with async parallel uploads, automatic retries, and progress reporting.
Features
- 🚀 Async Parallel Uploads: Upload multiple files simultaneously for improved performance
- 🔄 Automatic Retry: Configurable retry logic with exponential backoff for failed uploads
- 📊 Progress Tracking: Real-time progress bar showing upload status
- 📈 Detailed Reporting: Summary statistics showing successful, failed, and skipped files
- 🔐 Flexible Authentication: Support for password and SSH key authentication
- 🌳 Recursive Upload: Maintain directory structure when uploading folders
- ⚙️ Environment Variables: Configure settings via environment variables
Installation
cd tools/upload-sftp
pip install -e .
Usage
Basic Usage
upload-sftp /path/to/local/folder /remote/folder \
--host sftp.example.com \
--username myuser \
--password mypassword
Using SSH Key Authentication
upload-sftp /path/to/local/folder /remote/folder \
--host sftp.example.com \
--username myuser \
--key-file ~/.ssh/id_rsa
Advanced Options
upload-sftp /path/to/local/folder /remote/folder \
--host sftp.example.com \
--port 2222 \
--username myuser \
--password mypassword \
--max-workers 20 \
--max-retries 5 \
--no-recursive
Using Environment Variables
Create a .env file or export environment variables:
export SFTP_HOST=sftp.example.com
export SFTP_PORT=22
export SFTP_USERNAME=myuser
export SFTP_PASSWORD=mypassword
# Or use key file:
# export SFTP_KEY_FILE=~/.ssh/id_rsa
Then run without specifying these options:
upload-sftp /path/to/local/folder /remote/folder
Command-Line Options
| Option | Short | Description | Default | Environment Variable |
|---|---|---|---|---|
--host |
-h |
SFTP server hostname | Required | SFTP_HOST |
--port |
-p |
SFTP server port | 22 | SFTP_PORT |
--username |
-u |
SFTP username | Required | SFTP_USERNAME |
--password |
SFTP password | None | SFTP_PASSWORD |
|
--key-file |
-k |
SSH private key file | None | SFTP_KEY_FILE |
--max-workers |
-w |
Max parallel uploads | 10 | - |
--max-retries |
-r |
Max retries per file | 3 | - |
--recursive |
Upload recursively | True | - | |
--no-recursive |
Don't upload recursively | - | - |
Example Output
Starting SFTP Upload
Local folder: /Users/john/documents
Remote folder: /backup/documents
SFTP host: sftp.example.com:22
Max parallel workers: 10
Max retries per file: 3
Uploading files... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Upload Summary
Total files found: 150
Successfully uploaded: 148
Failed: 2
Skipped: 0
Total time: 12.45 seconds
Failed Files:
• /Users/john/documents/large_file.zip: Connection timeout
• /Users/john/documents/locked.txt: Permission denied
Performance Tips
- Adjust Workers: Increase
--max-workersfor better performance on fast connections - Network Optimization: Use servers geographically closer to reduce latency
- Retry Configuration: Adjust
--max-retriesbased on network stability - File Size: Larger files benefit less from parallel uploads
Error Handling
The tool automatically retries failed uploads with exponential backoff:
- 1st retry: 1 second wait
- 2nd retry: 2 seconds wait
- 3rd retry: 4 seconds wait
- And so on...
Failed uploads are reported at the end with specific error messages.
Security Notes
⚠️ Important: The tool currently disables SSH host key verification for convenience. For production use, consider implementing proper host key verification.
Requirements
- Python 3.13+
- asyncssh
- typer
- rich
Development
# Install in development mode
pip install -e .
# Run directly
python -m upload_sftp.cli --help
License
Part of the LateralCare project.
Metadata
Release files for upload-sftp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| upload_sftp-0.1.0.tar.gz | 6.6 kB | Without provenance | Details for upload_sftp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| upload_sftp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for upload_sftp-0.1.0-py3-none-any.whl |
Total release size: 14.1 kB
Release files / upload_sftp-0.1.0.tar.gz
| Download URL | upload_sftp-0.1.0.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
972a3ac26376721e65f5c78580dbe5124d7d4d78bac18d709953199c97290b9d
|
|
BLAKE2b-256 checksum How to use checksums |
b925f71ad200d7581c5fefbbaedf2b1181135d90d5b62c841bb89d25594c256f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.28
|
Release files / upload_sftp-0.1.0-py3-none-any.whl
| Download URL | upload_sftp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1ffa5033ab6b2a8920eb0512e9db806875ef5a91121f16b7a4ef0ac591e907b4
|
|
BLAKE2b-256 checksum How to use checksums |
be9f85de0603adbbfceea0232ce9320d00c6ac0bdb968bf9d22de16ef0b04307
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.28
|
Security for upload-sftp 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.