Lanchon / openwrt-rt4230w-rev6

OpenWrt installation instructions for Askey RT4230W REV6 / RAC2V1K
Other
9 stars 1 forks source link

Fix SCP client could not find SFTP binary #3

Closed GNU-Linuxer closed 1 year ago

GNU-Linuxer commented 1 year ago

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/

Lanchon commented 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.

GNU-Linuxer commented 1 year ago

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?

Lanchon commented 1 year ago

for reference:

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 extension expand-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.

GNU-Linuxer commented 1 year ago

Thank you very much for confirming. Feel free to merge it and close my PR.

Lanchon commented 1 year ago

fixed by 4ae1ac13037fc7c338308bb18505d0b410834994

thank you!!

Lanchon commented 1 year ago

also applied to another router: https://github.com/Lanchon/openwrt-tr4400-v2/commit/453e6750d32e1998ffe7b6bb8d0d5b514ec39cf3

Lanchon commented 1 year ago

sorry, i had to force push commits because of typos :(

43fb5fb4b85861ac6d66f67638533754a8f6e214 https://github.com/Lanchon/openwrt-tr4400-v2/commit/5fd99bd2712e6eb38b601f079ee0918d60643a16