SSH backups failing to Windnows 2025 OpenSSH server

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Post Reply
boomshnka
Posts: 3
Joined: Tue Dec 03, 2024 11:52 am

SSH backups failing to Windnows 2025 OpenSSH server

Post by boomshnka »

Hello all. I have a new installation of NagiosXI (2024R1.3.1) and am struggling to get SSH backups to work. My desired backup server is running Windows Server 2025 with the default OpenSSH service enabled. I am using this same system for other Linux based systems that utilize SSH/SFTP/SCP for backups. From the Nagios system, I am able to manually scp a file to the Windows server with the same configured credentials and destination folder. Using the Test SCP Transfer button yields the following errors:

Code: Select all

Could not transfer file. Permissions may be wrong or folder may not exist.
I see the following in the /var/log/php-fpm/www-error.log file when using the Test SCP Transfer button:

Code: Select all

[03-Dec-2024 09:42:49] WARNING: [pool www] child 3852453 said into stderr: "NOTICE: PHP message: PHP Warning:  ssh2_scp_send(): Failure creating remote file: failed to send file (-28) in /usr/local/nagiosxi/html/includes/components/scheduledbackups/ajaxcalls.php on line 0"
The /usr/local/nagiosxi/var/components/scheduledbackups.log (even with debug logging enabled) only shows the following after a failed scheduled backup:

Code: Select all

\nStarting new backup....\n
Backing up Nagios Core...
tar: Removing leading `/' from member names
tar: /usr/local/nagios/var/rw/nagios.qh: socket ignored
Backing up Nagios XI...
tar: Removing leading `/' from member names
Backing up MRTG...
tar: Removing leading `/' from member names
Backing up the SNMP directories
tar: Removing leading `/' from member names
tar: Removing leading `/' from member names
Backing up NRDP...
tar: Removing leading `/' from member names
Backing up Nagvis...
tar: Removing leading `/' from member names
Backing up nagios user home dir...
tar: Removing leading `/' from member names
Backing up MySQL databases...
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: [Warning] Using a password on the command line interface can be insecure.
Backing up cronjobs for Apache...
Backing up logrotate config files...
Backing up Apache config files...
Compressing backup...

===============
BACKUP COMPLETE
===============
Backup stored in /store/backups/nagiosxi/nagiosxi.1733245263.tar.gz
12-03-2024 10:01:45 ERROR: Scheduled SSH Backup Failed: File was not transferred successfully
If I reconfigure the SSH backup to use an Ubuntu 24.04 system as the destination it works fine.

Given that I can manually SCP files from the Nagios system to the Windows server, but doing so via Nagios is failing, I imagine this is likely an issue with the ssh2_scp_send PHP module. If so, I'm not sure how to begin troubleshooting that. Any thoughts on this issue would be greatly appreciated. Thanks.
sgardil
Posts: 355
Joined: Wed Aug 09, 2023 9:58 am

Re: SSH backups failing to Windnows 2025 OpenSSH server

Post by sgardil »

boomshnka wrote: Tue Dec 03, 2024 12:07 pm Hello all. I have a new installation of NagiosXI (2024R1.3.1) and am struggling to get SSH backups to work. My desired backup server is running Windows Server 2025 with the default OpenSSH service enabled. I am using this same system for other Linux based systems that utilize SSH/SFTP/SCP for backups. From the Nagios system, I am able to manually scp a file to the Windows server with the same configured credentials and destination folder. Using the Test SCP Transfer button yields the following errors:

Code: Select all

Could not transfer file. Permissions may be wrong or folder may not exist.
I see the following in the /var/log/php-fpm/www-error.log file when using the Test SCP Transfer button:

Code: Select all

[03-Dec-2024 09:42:49] WARNING: [pool www] child 3852453 said into stderr: "NOTICE: PHP message: PHP Warning:  ssh2_scp_send(): Failure creating remote file: failed to send file (-28) in /usr/local/nagiosxi/html/includes/components/scheduledbackups/ajaxcalls.php on line 0"
The /usr/local/nagiosxi/var/components/scheduledbackups.log (even with debug logging enabled) only shows the following after a failed scheduled backup:

Code: Select all

\nStarting new backup....\n
Backing up Nagios Core...
tar: Removing leading `/' from member names
tar: /usr/local/nagios/var/rw/nagios.qh: socket ignored
Backing up Nagios XI...
tar: Removing leading `/' from member names
Backing up MRTG...
tar: Removing leading `/' from member names
Backing up the SNMP directories
tar: Removing leading `/' from member names
tar: Removing leading `/' from member names
Backing up NRDP...
tar: Removing leading `/' from member names
Backing up Nagvis...
tar: Removing leading `/' from member names
Backing up nagios user home dir...
tar: Removing leading `/' from member names
Backing up MySQL databases...
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: [Warning] Using a password on the command line interface can be insecure.
Backing up cronjobs for Apache...
Backing up logrotate config files...
Backing up Apache config files...
Compressing backup...

===============
BACKUP COMPLETE
===============
Backup stored in /store/backups/nagiosxi/nagiosxi.1733245263.tar.gz
12-03-2024 10:01:45 ERROR: Scheduled SSH Backup Failed: File was not transferred successfully
If I reconfigure the SSH backup to use an Ubuntu 24.04 system as the destination it works fine.

Given that I can manually SCP files from the Nagios system to the Windows server, but doing so via Nagios is failing, I imagine this is likely an issue with the ssh2_scp_send PHP module. If so, I'm not sure how to begin troubleshooting that. Any thoughts on this issue would be greatly appreciated. Thanks.
Hey @boomshnka

It sounds like theres an issue with the php command and possibly permissions on the server. After doing some research it seems that scp and php's ssh2_scp_send work somewhat differently so its not too alarming that scp works and the other does not. When you use the scp command what user are you logged in as when it works? Have you tried using the nagios user and seeing if the scp still works?
boomshnka
Posts: 3
Joined: Tue Dec 03, 2024 11:52 am

Re: SSH backups failing to Windnows 2025 OpenSSH server

Post by boomshnka »

It sounds like theres an issue with the php command and possibly permissions on the server. After doing some research it seems that scp and php's ssh2_scp_send work somewhat differently so its not too alarming that scp works and the other does not. When you use the scp command what user are you logged in as when it works? Have you tried using the nagios user and seeing if the scp still works?
Thank you for the quick reply. I had been testing this as root but just tested as the nagios user and I'm still able to manually scp files between the Nagios system and the Windows system.
jsimon
Posts: 343
Joined: Wed Aug 23, 2023 11:27 am

Re: SSH backups failing to Windnows 2025 OpenSSH server

Post by jsimon »

Hi @boomshnka,

As best I can tell from investigating this issue, the SSH backup functionality appears to not support Windows currently. There is some javascript in place that automatically appends a backslash to the end of the provided file path, and even if disabled it appears that currently entering a Windows filepath may have other issues that prevent this from working. I have created an issue in our internal tracking system to fix this and add support.

In the interim, you could try setting up a cron script to move your backup files for you. Apologies for the inconvenience!
boomshnka
Posts: 3
Joined: Tue Dec 03, 2024 11:52 am

Re: SSH backups failing to Windnows 2025 OpenSSH server

Post by boomshnka »

As best I can tell from investigating this issue, the SSH backup functionality appears to not support Windows currently. There is some javascript in place that automatically appends a backslash to the end of the provided file path, and even if disabled it appears that currently entering a Windows filepath may have other issues that prevent this from working. I have created an issue in our internal tracking system to fix this and add support.

In the interim, you could try setting up a cron script to move your backup files for you. Apologies for the inconvenience!
No worries, thank you very much for the recommendation regarding cron. That will work fine.
Post Reply