SFTP Remote Backup Fails on SFTP-only Destinations (Hetzner Storage Box, etc.)

Bug Report: SFTP Remote Backup Fails on SFTP-only Destinations (Hetzner Storage Box, etc.)

Summary:
CyberPanel’s Remote Backup feature cannot add SFTP destinations when the remote server supports SFTP only (no SSH shell), such as Hetzner Storage Box and many shared hosting providers. The panel tries to run remote shell commands (mkdir, chmod, etc.), which are not permitted, resulting in “Channel closed” errors.

Steps to Reproduce:

  1. Go to Backups > Add SFTP Destination in CyberPanel.
  2. Enter credentials for a remote SFTP server (e.g. Hetzner Storage Box) that supports SFTP only and does not allow SSH shell access.
  3. Choose Password authentication (not SSH key).
  4. Click Test Connection or Add Destination.

Expected Result:

  • CyberPanel should add the SFTP destination and allow remote backups using password authentication, with no attempt to run shell commands.

Actual Result:

  • CyberPanel attempts to run shell commands like mkdir -p .ssh, chmod, and cp on the remote server.
  • Since the SFTP server does not allow shell access, each command fails with:
    Error executing remote command mkdir -p .ssh. Error Channel closed.
    SSH error: Channel closed. [sendKey]
  • SFTP destination is not added, or backup cannot proceed.

Environment:

  • **CyberPanel Version: 2.4.2
  • **OS:**AlmaLinux 9
  • Remote SFTP Server: Hetzner Storage Box (your-storagebox.de)
  • Authentication: Password only

Notes:

  • The same SFTP credentials work with rclone, sftp, FileZilla, and other tools—no issues with file transfer.
  • Other panels (DirectAdmin, Plesk) have similar issues and offer a “pure SFTP mode” (no shell commands) for such storage.
  • This bug affects all SFTP-only remote storage, not just Hetzner.

Suggested Solution:

  • Add a “pure SFTP mode” to CyberPanel remote backup, which does not attempt to run shell commands on the remote and relies only on SFTP file operations, especially when password authentication is selected.
  • Optionally, detect and warn users if shell commands cannot be executed, and fallback to password-based SFTP only.

Workaround:

  • Use rclone or another external tool for remote SFTP backups until this is fixed.

Thank you for considering this improvement, it will help many users who need to back up to SFTP-only destinations!

Thank you for reporting this issue. I’ve implemented a fix that adds support for SFTP-only destinations like Hetzner Storage Box.

What was the problem:

CyberPanel was trying to execute SSH shell commands (like mkdir -p .ssh, chmod, etc.) which are not supported on SFTP-only servers, causing the “Channel closed” errors.

What the fix does:

  • The system now attempts SSH commands first (maintaining backward compatibility)
  • If SSH commands fail or are rejected, it automatically falls back to pure SFTP operations
  • File transfers will use SFTP instead of SCP when SSH is not available
  • Directory creation and file operations are handled via SFTP protocol

Changes made:

  1. Modified setupSSHKeys to detect and handle SFTP-only servers
  2. Updated backup transfer mechanisms to use SFTP when SCP fails
  3. Added fallback for directory operations using SFTP
  4. Improved error handling to gracefully handle SFTP-only environments

The fix is implemented in CyberPanel v2.4.2. For those using SFTP-only destinations:

  • Password authentication will work seamlessly
  • The system will automatically detect the SFTP-only environment
  • Backups will be transferred using pure SFTP protocol

This ensures CyberPanel works with both regular SSH servers and SFTP-only destinations like Hetzner Storage Box, rsync.net, and similar services.

The fix maintains full backward compatibility - existing setups will continue to work exactly as before.

You can upgrade to get the fix.