When working with third-party SFTP servers, checking available storage isn't as straightforward as local systems. Unlike regular SSH access which provides direct shell commands, SFTP implementations often restrict users to file transfer protocols only. Here's what you need to know about different approaches.
Many SFTP servers support the df
command despite being in SFTP mode. Try this sequence after connecting:
sftp> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 42G 5.4G 89% /
In FileZilla Pro (version 3.55+), enable disk space checking:
1. Go to Edit > Settings > Interface
2. Check "Show disk space in message log"
3. Right-click server > "Calculate current directory size"
If the server allows SSH access (even if restricted), try these commands:
# Basic disk usage
df -h
# Detailed per-directory analysis
du -sh /path/to/directory
# For user-specific quota (if enabled)
quota -vs
The error you encountered suggests the server uses scponly
or rssh
for security. Workarounds include:
- Ask provider to enable
df
in SFTP - Request read-only SSH access for monitoring
- Use provider's API if available (common with AWS Transfer Family, etc.)
Here's a Python script using Paramiko for regular checks:
import paramiko
def check_sftp_space(host, username, key_path):
transport = paramiko.Transport((host, 22))
private_key = paramiko.RSAKey.from_private_key_file(key_path)
transport.connect(username=username, pkey=private_key)
sftp = paramiko.SFTPClient.from_transport(transport)
try:
stdout = sftp.open('/proc/mounts').read()
# Parse disk info - adjust based on server OS
print("Raw mounts info:", stdout)
finally:
sftp.close()
transport.close()
check_sftp_space('your.server.com', 'user', '/path/to/key.pem')
For locked-down environments:
- Monitor transfer failures - many servers return specific errors when full
- Create test files of known sizes to estimate remaining space
- Check provider's control panel for storage metrics
When working with third-party hosted SFTP servers, administrators often face the challenge of monitoring disk space without direct shell access. Traditional methods like df -h
become unavailable when the provider restricts command execution.
Method 1: Using SFTP Clients with Built-in Features
Applications like FileZilla Pro (v3.63+) can display server space information:
1. Connect to your SFTP server
2. Right-click on root directory (/)
3. Select "Directory usage..."
4. View total/used/free space
Method 2: Script-Based Solution with lftp
For automated monitoring, consider this bash script using lftp:
#!/bin/bash
HOST="your.sftp.server"
USER="username"
PASS="password"
lftp -u $USER,$PASS sftp://$HOST <
The error message you encountered suggests the server is running scponly (a restricted shell). Try these workarounds:
- Use
sftp
command instead of ssh:sftp -i keyfile user@host
- For Windows, WinSCP's "Server and Protocol Information" dialog shows disk space
For regular monitoring, create a Python script using Paramiko:
import paramiko
transport = paramiko.Transport(('hostname', 22))
transport.connect(username='user', password='pass')
sftp = paramiko.SFTPClient.from_transport(transport)
try:
statvfs = sftp.statvfs('/')
total = (statvfs.f_blocks * statvfs.f_frsize) / (1024**3)
used = ((statvfs.f_blocks - statvfs.f_bfree) * statvfs.f_frsize) / (1024**3)
print(f"Total: {total:.2f}GB, Used: {used:.2f}GB")
finally:
sftp.close()
If none of these methods work due to server restrictions:
- Create a test file of known size (e.g., 1MB)
- Monitor upload failures that indicate full storage
- Implement client-side quota tracking by summing uploaded files