Configuration
Required Settings
Full SFTP store URI, e.g.
sftp://backupuser@backup.example.com/backup/cloudstic or sftp://backupuser@backup.example.com:2222/backup/cloudsticAuthentication Methods
Cloudstic supports three authentication methods for SFTP, tried in order:- SSH Key (Recommended)
- Password
- SSH Agent
Path to SSH private key file (PEM format)
Path to custom
known_hosts file for host key validation.Set to
true to skip host key validation (INSECURE).SSH keys provide the most secure authentication. Ensure the private key has proper permissions:
chmod 600 ~/.ssh/id_rsaExamples
- Basic Setup
- Custom Port
- Multiple Repositories
- Automated Backup
Server Setup
Create Backup User
On the SFTP server, create a dedicated user for backups:Configure SSH Key
Restrict Access (Optional)
For additional security, restrict the backup user to SFTP only:With
ChrootDirectory, the backup user is confined to /backup and cannot access other parts of the filesystem.Features
Atomic Writes
The SFTP store ensures safe writes:- Data is written to a temporary file with
.tmpsuffix PosixRenameatomically moves the temp file to final location- Interrupted writes never corrupt existing data
Directory Auto-Creation
The SFTP store automatically creates directories as needed:- Nested directory creation
- Chroot environments with read-only parent directories
- Race conditions with concurrent operations
Connection Management
SFTP connections are maintained for the duration of the operation:- Single persistent connection per operation
- Reused for all file operations (Put, Get, List)
- Automatically closed when operation completes
Performance
Upload Speed
SFTP performance depends on:- Network latency: Higher latency reduces throughput
- CPU (encryption): SSH encryption is CPU-intensive
- Disk I/O: Both client and server disk speed matter
- LAN (1 Gbps): 50-100 MB/s
- Internet (100 Mbps): 8-12 MB/s
- High latency: Limited by round-trip time
Optimization Tips
- Compression
- Cipher Selection
- ControlMaster
Cloudstic already compresses data with zstd. For additional SSH-level compression:This can help over slow connections but adds CPU overhead.
Troubleshooting
Permission Denied
If you see “permission denied” errors:Connection Refused
If the connection is refused:Chroot Issues
If usingChrootDirectory, ensure:
Authentication Failed
If authentication fails with no clear error:Slow Performance
If backups are slow:- Test network speed:
iperf3 -c backup.example.com - Check latency:
ping backup.example.com - Enable compression: Add
Compression yesto SSH config - Use faster cipher:
chacha20-poly1305@openssh.com - Check disk I/O:
iostat -x 1on both client and server
Security Considerations
Host Key Verification
Cloudstic strictly validates the remote SFTP server’s host key against your localknown_hosts file. This prevents Man-in-the-Middle attacks.
To add a host key manually:
-store-sftp-known-hosts to specify a non-default file, or -store-sftp-insecure to skip validation entirely (not recommended for production).
Key Management
- Use separate SSH keys for backups (not your personal key)
- Set appropriate key permissions:
chmod 600 ~/.ssh/backup_key - Use Ed25519 keys for better security and performance
- Rotate keys periodically
Server Hardening
Network Security
- Use firewall rules to restrict access to backup server
- Consider VPN for backups over untrusted networks
- Monitor authentication logs for suspicious activity
Data at Rest
Cloudstic encrypts all data client-side before uploading:- Encryption: AES-256-GCM
- Key derivation: HKDF with per-repository master key
- Metadata: Also encrypted (except
configandkeys/prefix)
Comparison with Other Backends
- SFTP vs Local
- SFTP vs S3/B2
SFTP Advantages:
- Remote storage (off-site backup)
- Accessible over network
- No direct server access needed
- Faster (no network overhead)
- Simpler setup
- No SSH configuration
Related Resources
Backup Command
Create backups to SFTP
Local Storage
Local filesystem storage
S3 Storage
Cloud storage alternative
Encryption
Data encryption details