SFTP - check free space available

2019-05-31 18:47发布

问题:

I'm using Renci SSH.NET library for secure ftp connection. Now I have to check free disk space available on remote SFTP server. How can I do this?

回答1:

As Eugene commented, SFTP protocol version 6 lets one check available space (SSH_FXP_EXTENDED request name space-available).

But Renci SSH.NET library supports SFTP protocol version 3 only. Also worth noting that most SSH/SFTP servers (notably OpenSSH, as the one the most widespread) support SFTP version 3 only too. So client-side support won't help much here.

As Salva has commented, OpenSSH on the other hand supports statvfs@openssh.com proprietary extension. And Renci SSH.NET library supports that too (via SftpClient.GetStatus). So if you are sure that you work against OpenSSH server, you can use that.