After I upgraded my Debian 11 Bullseye system to Debian 12 Bookworm recently, I occasionally found the scp command between Debian 12 Bookworm on my PC and OpenWRT 22.03 on my router was broken. The error message is
ash: /usr/libexec/sftp-server: not found
scp: Connection closed
After debugging, I found the root cause.
The change comes from the default OpenSSH version change of debian, Debian 11 Bullseye uses OpenSSH 8.4 but Debian 12 Bookworm uses OpenSSH 9.2. Due to the release note of openssh 9.0. Since OpenSSH 9.0, OpenSSH switches scp from using the legacy scp/rcp protocol to using the sftp protocol by default.
The solution is quite simple. We have two choices,
scp -O source_user@source_machine:source_path destination_user@destination_machine:destination_path
opkg update
opkg install openssh-sftp-server