Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

ptosti

Re: -criteria=checksum fails second authentication

Hi Martin,
The server is TrueNAS 25.10 Community Edition, it does not have a specific sftp server, as it is built in, "allegedly".
WinSCP does seem to connect ok if I remove the checksum option.
So, without the checksum option, the scripts runs fine, files are transferred if missing on destination, BUT, randomly, some files, not all,are filled with "00" (zero value bytes), that is, files are transferred, operation completes without errors.
Running FC.exe on Windows between the downloaded corrupt file and original one, shows the corrupted (transferred) file has "00" in it while the original one does have actual data.

I got SftpScpFallback=0 from a Google search, apparently this is supposed to stop WinSCP falling back to SCP Protocol if SFTP fails....
martin

Re: -criteria=checksum fails second authentication

If your SFTP server does not support calculating checksums (what is common – as particularly common OpenSSH server does not support it), then WinSCP indeed falls back to using shell commands to calculate the checksums.
https://winscp.net/eng/docs/protocols#checksum

I'm confused about the "files filled with 00" problem. Is this related to the checksum problem? Or did you resolve it somehow?

(Btw, there's nothing like SftpScpFallback=0).
ptosti

Re: -criteria=checksum fails second authentication

Hi Martin,
Yes, that was it I think, however, it now falls back to scp, not SFTP protocol.
What I am trying to achieve is as follows:
I distribute an SSD filled with all the software for our equipment, around 300GB all up.
I am trying to make it as simple as possible for the people in the field, so that they just click on a batch file, it runs and the SSD is updated as required.
The client is Windows 11, the server is TrueNAS 25.10, SFTP, SSH using Private/Public key.
The target is an SSD with 2 partitions, one is a Windows recovery (our equipment boots from this), the other contains the data, WinSCP and related files are copied in a folder of the recovery partition.
The original command was working, however I would get random files filled with "00" instead of actual data. Original command was:
synchronize local -delete -mirror -rawtransfersettings[1] ExcludeHiddenFiles=1 %targetdrive%\ /service/software/SSD

So I added the -transfer=binary -resumesupport=off, no joy, eventually I ended up with:
synchronize local -delete -mirror -transfer=binary -resumesupport=off -criteria=checksum -rawtransfersettings[2] ExcludeHiddenFiles=1 SftpScpFallback=0 %targetdrive%\ /service/software/SSD

But for some reasons, this causes the protocol to switch from SFTP to SCP and it fails....
The default shell on TrueNAS was zsh, later changed to bash, service restarted, but still getting error.
I have attached that starting batch file, the sync.txt referred by it and the error log.
Note this transfer tests are currently happening on a local network at the moment, so no slow internet.
Hope you can shed some light on it.
Many thanks!
martin

Re: -criteria=checksum fails second authentication

Hard to tell without a log file.
But it seems that you are specifying the key with just file name (so relatively to your working directory). If the script changes the working directory (lcd) before the synchronize, the key.ppk stops being valid.
If this does not help, please post a log file.

To generate the session log file, use /log=C:\path\to\winscp.log command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
ptosti

-criteria=checksum fails second authentication

Hello, I am at my wits end with a script supposed to synchronize a local folder with a remote folder, this works:
synchronize local -delete -mirror -rawtransfersettings[1] ExcludeHiddenFiles=1 H:\ /service/software/SSD

But if I add -criteria=checksum:
synchronize local -delete -mirror -criteria=checksum -rawtransfersettings[1] ExcludeHiddenFiles=1 H:\ /service/software/SSD

This causes the second part of the authentication to fail, reason given is that it cannot read the private key.

Script: Credentials were not specified.
< 2026-04-25 14:26:14.752 Authentication log (see session log for details):
< 2026-04-25 14:26:14.752 Unable to use key file "key.ppk" (unable to open file)
< 2026-04-25 14:26:14.752 Using username "key".
< 2026-04-25 14:26:14.752
< 2026-04-25 14:26:14.752 Authentication failed.
. 2026-04-25 14:26:14.752 Script: Failed

If I just remove the -criteria=checksum switch from the command, everything is fine.

Any idea?

Thanks