After update to Fedora 43, SCP fails when run by cron but runs fine from terminal

I have a bash script that uses SCP to download files from a remote server. The script runs correctly when run from terminal but fails when run by cron giving this error:

Host key verification failed.

This script worked correctly when run by cron on Fedora 42. Here’s the script (note: src_server.com has been changed for posting. The actual actual script uses the correct domain name):

fname=“/home1/wtsdoe1e/public_html/app/backups/*”

scp wtsdoe1e@src_server.com:${fname} /WDB/WTS/All_Backups/

The source files exist and the script worked correctly previous on Fedora 42 and works correctly now when run in terminal. Any help will be greatly appreciated. TIA

Hi Paul,

This looks like an error caused by the UID that this crontab belongs to. Check to see if it is executing as the same UID that you are using to test it. The error is basically saying “I can’t find the knwon_hosts file with this target’s address/name in it” …

Not directly related, but you may find it is alot easier to use a systemd timer and servicebunit then cron tab for this.

This error means that the host you are connecting to identification key has changed. Did the server you are connecting to also change or update it’d SSHD server?

Make sure the user the crontab is running under has properly configured known_hosts.

man ssh_config and read the description for option StrictHostKeyChecking
Also, man ssh and reading section VERIFYING HOST KEYS may help.

ssh will refuse to connect in non-interactive sessions, if the host key did not match or was unknown.