How to check diskspace on SFTP server

Solution 1:

The scponly shell may allow the quota command (if enabled). But it seems that you have the scponly configured to support the SFTP only, with a shell access disallowed.

The SFTP protocol allows checking disk space (contrary to what other answers say).

Extracting from the SFTP - check free space available question of stackoverflow.com:

SFTP protocol version 6 lets one check available space (SSH_FXP_EXTENDED request name space-available). Most SSH/SFTP servers (notably OpenSSH, as the one the most widespread) support SFTP version 3 only though.

OpenSSH on the other hand supports [email protected] proprietary extension.

The OpenSSH extension is supported by some SFTP clients.

  • Obviously by the OpenSSH sftp client via the df command:

    df [-hi] [path]
    Display usage information for the filesystem holding the current directory (or path if specified). If the -h flag is specified, the capacity information will be displayed using "human-readable" suffixes. The -i flag requests display of inode information in addition to capacity information. This command is only supported on servers that implement the ''[email protected]'' extension.

    sftp> df -h
        Size     Used    Avail   (root)    %Capacity
       591GB    358GB    203GB    233GB          60%
    
  • WinSCP also supports it (see Server and Protocol Information Dialog):

    WinSCP Server and Protocol Information Dialog

    (I'm the author of WinSCP)

Solution 2:

ssh <host> df -h

Will give you all of the necessary information, in the absence of things like disk quotas. If you don't have shell access (or some way of running commands, such as via PHP exec), then you can't check disk space, but then again, if you don't have shell, how can it be your responsibility to administer the server and manage disk space?