All Articles

SCP Issue between Debian 12 Bookworm and OpenWRT 22.03

openssh-debian-openwrt

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.

  1. the scp server side, OpenWRT 22.03 uses Dropbear v2022.82 which only supports legacy scp protocol by default
  2. the scp client side, Debian 12 Bookworm uses OpenSSH 9.2 which requires sftp protocol by default

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,

  1. By following the man page of scp, we can add the “-O” option to force using the legacy scp protocol on the client side to avoid this error, like
scp -O source_user@source_machine:source_path destination_user@destination_machine:destination_path
  1. Another choice is to install sftp server on the server side, to enable the sftp protocol support
opkg update
opkg install openssh-sftp-server

Published Nov 12, 2023

Flying code monkey