scp error: path canonicalization failed

If you’re doing scp command, with ‘-r’ recursive option, and stumble upon a strange “path canonicalization failed” out of nowhere:

Starting from SSH 9.0.0 scp is using sFTP to copy files. And in sFTP, target directories must exist.

Simple fix: use -O, legacy mode:

“Use the legacy SCP protocol for file transfers instead of the SFTP protocol. Forcing the use of the SCP protocol may be necessary for servers that do not implement SFTP, for backwards-compatibility for particular filename wildcard patterns and for expanding paths with a `~’ prefix for older SFTP servers”