Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: OpenSSH scp completion reminder



On 2022-04-14 at 18:18 +0200, Axel Beckert wrote:
> I thought so as well, but I so far couldn't find anything which didn't
> work with zsh remote file completion with OpenSSH 9.0 on the client
> side. Otherwise I would have reported it.

What version was the server running?

With localhost being 9.0 for client and server and zsh 5.8, I see this
reproduction case; setup, then the results of tab-completion, and then
at the end a manually-constructed filename which definitely would not
have worked with older scp.

% pwd
/home/pdp/t3
% ls -lR
.:
total 4
drwxr-xr-x 2 pdp pdp 4096 Apr 14 16:31 'foo bar'$'\t''baz'

'./foo bar'$'\t''baz':
total 8
-rw-r--r-- 1 pdp pdp 4785 Apr 14 16:31 'An Artist - Foo Bar Baz.mp3'

% cd ~/Downloads/t
% scp localhost:t3/<TAB><TAB><ENTER>
% scp localhost:t3/foo\\\ bar\$\'\\t\'baz/An\\\ Artist\\\ -\\\ Foo\\\ Bar\\\ Baz.mp3 .
/opt/openssh/bin/scp: t3/foo\\ bar$'\\t'baz/An\\ Artist\\ -\\ Foo\\ Bar\\ Baz.mp3: No such file or directory

% scp $'localhost:t3/foo bar\tbaz/An Artist - Foo Bar Baz.mp3' .
An Artist - Foo Bar Baz.mp3                100% 4785     2.1MB/s   00:00

% ssh -V
OpenSSH_9.0p1, OpenSSL 1.1.1f  31 Mar 2020

So the good news is that scp in the new mode is "pass the filename
exactly as it really is, no escaping for the remote side, whatever
reaches us in argv[] is what will be used, so you only need to worry
about local shell escaping".

Note that scp(1) does not have a version flag, whereas ssh(1) does.
It might be reasonable to expect them to be paired.  Invoking `scp -O`
exits 1 in both versions below, but you can see the output text
differences.  -O to use original SCP protocol, -s to use sftp protocol.
-D is for local debugging.

So I think full support means knowing the version, knowing which version
switched the default behaviour (looks like 9.0 man-page might be wrong),
and then knowing which options have been set on the command-line already
for this version.

OpenSSH 9.0:
usage: scp [-346ABCOpqRrsTv] [-c cipher] [-D sftp_server_path] [-F ssh_config]
           [-i identity_file] [-J destination] [-l limit]
           [-o ssh_option] [-P port] [-S program] source ... target
OpenSSH 8.6:
/usr/bin/scp: unrecognized option: O
usage: scp [-346ABCpqrTv] [-c cipher] [-F ssh_config] [-i identity_file]
            [-J destination] [-l limit] [-o ssh_option] [-P port]
            [-S program] source ... target

-Phil




Messages sorted by: Reverse Date, Date, Thread, Author