Closed GNU-Linuxer closed 1 year ago
hi,
good catch, and thanks for the patch!!
i'm a little hesitant to merge this, as not everybody is running the latest and greatest system out there (obviously, i'm one of those). i'm wondering if a textual description of the possible scp error and how to fix it adding -O
would be better. or otherwise instructions to leave said option out if it's unrecognized.
whatever we do, thank a bunch for the info. i was completely unaware of this.
Here's the scp error without -O
flag when transferring file TO RAC2V1K:
% scp file root@192.168.1.1:/
root@192.168.1.1's password: <entered correct password>
ash: /usr/libexec/sftp-server: not found
scp: Connection closed
%
I believe there is no other workaround unless the Spectrum stock firmware and the OpenWRT's default dropbear ssh client supports SFTP.
Also, old SCP version do not support -O flag. I've attempted to execute scp -O
on Ubuntu 14.04 and it says unknown option.
Hence I wonder what's a better way to inform users about the SCP issue?
for reference:
OpenSSH 8.7 (2021-08-20): https://www.openssh.com/txt/release-8.7
scp(1): experimental support for transfers using the SFTP protocol as a replacement for the venerable SCP/RCP protocol that it has traditionally used. SFTP offers more predictable filename handling and does not require expansion of glob(3) patterns via the shell on the remote side.
SFTP support may be enabled via a temporary scp -s flag. It is intended for SFTP to become the default transfer mode in the near future, at which time the -s flag will be removed. The -O flag exists to force use of the original SCP/RCP protocol for cases where SFTP may be unavailable or incompatible.
OpenSSH 9.0 (2022-04-08): https://www.openssh.com/txt/release-9.0
This release switches scp(1) from using the legacy scp/rcp protocol to using the SFTP protocol by default.
Legacy scp/rcp performs wildcard expansion of remote filenames (e.g.
scp host:* .
) through the remote shell. This has the side effect of requiring double quoting of shell meta-characters in file names included on scp(1) command-lines, otherwise they could be interpreted as shell commands on the remote side.This creates one area of potential incompatibility: scp(1) when using the SFTP protocol no longer requires this finicky and brittle quoting, and attempts to use it may cause transfers to fail. We consider the removal of the need for double-quoting shell characters in file names to be a benefit and do not intend to introduce bug-compatibility for legacy scp/rcp in scp(1) when using the SFTP protocol.
Another area of potential incompatibility relates to the use of remote paths relative to other user's home directories, for example -
scp host:~user/file /tmp
. The SFTP protocol has no native way to expand a ~user path. However, sftp-server(8) in OpenSSH 8.7 and later support a protocol extensionexpand-path@openssh.com
to support this.In case of incompatibility, the scp(1) client may be instructed to use the legacy scp/rcp using the -O flag.
most people are probably on SCP >= 8.7, where -O might not needed but is supported, so i guess this PR is OK. FYI, current ubuntu LTS (jammy) -which is the base for many distros- uses ssh 8.9.
Thank you very much for confirming. Feel free to merge it and close my PR.
fixed by 4ae1ac13037fc7c338308bb18505d0b410834994
thank you!!
also applied to another router: https://github.com/Lanchon/openwrt-tr4400-v2/commit/453e6750d32e1998ffe7b6bb8d0d5b514ec39cf3
sorry, i had to force push commits because of typos :(
43fb5fb4b85861ac6d66f67638533754a8f6e214 https://github.com/Lanchon/openwrt-tr4400-v2/commit/5fd99bd2712e6eb38b601f079ee0918d60643a16
The OpenWRT dropbear SSH server does not support SFTP protocol. Newer versions of SCP client will use SFTP by default unless adding a
-O
flag. I have updated the command to include this change. Tested on real RAC2V1K hardware to confirm my updated scp command is working properly.Source: https://blog.lancitou.net/scp-command-couldnt-find-sftp-server/