gazelle@shell.xmission.com (Kenny McCormack):
$ cd
$ mkdir 'this is a test'
$ scp -p .profile 'localhost:this is a test'
scp: ambiguous target
Status: 1
Does
scp -p .profile 'localhost:'\''this is a test'\'
work?
$ cd
$ mkdir 'this is a test'
$ scp -p .profile 'localhost:this is a test'
scp: ambiguous target
Status: 1
In article <83wnbqd5ol.fsf@helmutwaitzmann.news.arcor.de>,
Helmut Waitzmann <oe.throttle@xoxy.net> wrote:
gazelle@shell.xmission.com (Kenny McCormack):
$ cd
$ mkdir 'this is a test'
$ scp -p .profile 'localhost:this is a test'
scp: ambiguous target
Status: 1
Does
scp -p .profile 'localhost:'\''this is a test'\'
work?
Possibly. I'll have to test it at some point.
I kinda guessed that that was the underlying problem - that it gets
passed through two levels of shell and thus needs to be
doubly-quoted.
Still, it *should* work (as is) -
or at least be documented.
P.S. I've had similar situations with "ssh", where you have to
doubly-quote to get it to work. But there, it is explicit that two
shells are involved. With "scp", this is not made explicit.
$ cd
$ mkdir 'this is a test'
$ scp -p .profile 'localhost:this is a test'
scp: ambiguous target Status: 1
$ mv this\ is\ a\ test thisisatest $ scp -p .profile
'localhost:thisisatest'
(This time, it works)
$ rmdir 'thisisatest'
Apparently, scp can't handle directories with spaces in their names.
$ cd
$ mkdir 'this is a test'
$ scp -p .profile 'localhost:this is a test'
scp: ambiguous target
Status: 1
$ mv this\ is\ a\ test thisisatest
$ scp -p .profile 'localhost:thisisatest'
(This time, it works)
$ rmdir 'thisisatest'
Apparently, scp can't handle directories with spaces in their names.
On 2022-08-02, Kenny McCormack <gazelle@shell.xmission.com> wrote:
$ cd
$ mkdir 'this is a test'
$ scp -p .profile 'localhost:this is a test'
scp: ambiguous target
Status: 1
$ mv this\ is\ a\ test thisisatest
$ scp -p .profile 'localhost:thisisatest'
(This time, it works)
$ rmdir 'thisisatest'
Apparently, scp can't handle directories with spaces in their names.
It's a bit weird. According to this "how scp works" page,
retrievable thanks to archive.org:
https://web.archive.org/web/20170215184048/https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works
As of OpenSSH 9.0 (8.8/8.9 in OpenBSD), scp use the sftp protocol by
default, an eventuality alluded to in that Oracle article. Notably,
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.
Source: https://www.openssh.com/txt/release-9.0
It seems RHEL 9 switched the default mode even earlier. See >https://www.redhat.com/en/blog/openssh-scp-deprecation-rhel-9-what-you-need-know
tl;dr -> scp errs out if the target directory (on remote system) name has spaces in it.
tl;dr -> scp errs out if the target directory (on remote system) name has spaces in it.
$ scp file "RemSys:/path/that contains spaces"
Get an err msg something about "ambiguous target".
Workaround/fix is to double quote like thus:
$ scp file "RemSys:'/path/that contains spaces'"
I was able to figure this out, but it is weird.
On 2022-11-30, Kenny McCormack <gazelle@shell.xmission.com> wrote:
tl;dr -> scp errs out if the target directory (on remote system) name has
spaces in it.
Fixed in OpenSSH 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.
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.
I haven't gotten around to testing this, but it looks like adding:
-S /usr/lib/sftp-server
to the "scp" command line would enable the new behavior (i.e., unless/until
I get the newest versions of things installed on my system). Is that correct?
On 2022-12-01, Kenny McCormack <gazelle@shell.xmission.com> wrote:
I haven't gotten around to testing this, but it looks like adding:
-S /usr/lib/sftp-server
to the "scp" command line would enable the new behavior (i.e., unless/until >> I get the newest versions of things installed on my system). Is that
correct?
No. In either mode, scp will invoke ssh to connect to the remote
host:
$ scp foo host:bar
will spawn
/usr/bin/ssh -x -oPermitLocalCommand=no -oClearAllForwardings=yes \
-oRemoteCommand=none -oRequestTTY=no -oForwardAgent=no -s -- host sftp
$ scp -O foo host:bar
will spawn
/usr/bin/ssh -x -oPermitLocalCommand=no -oClearAllForwardings=yes \
-oRemoteCommand=none -oRequestTTY=no -oForwardAgent=no -- host scp -t bar
You can use the -S option to replace "/usr/bin/ssh" with something
else. The only practical use that comes to mind would be a wrapper
script that calls /usr/bin/ssh with some additional options, given
that scp doesn't have a configuration file.
- - - -
Nowadays people might no longer know, but Tatu Ylnen wrote ssh as
a drop-in replacement for the Berkeley rlogin/rsh/rcp suite. The
scp command was directly derived from the rcp code; rcp in turn had
been written by Bill Joy all the way back in 1982.
The completely revamped SSH2 protocol gained a whole file transfer >subprotocol (SFTP), for which OpenSSH has provided the sftp(1)
client. However, people prefer the scp(1) command line syntax, so
after years of hemming and hawing, OpenSSH has finally gone ahead
and moved scp over to SFTP, and fixed the quoting issue in the
process--or deliberately broke compatibility, however you want to
see it.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 497 |
Nodes: | 16 (2 / 14) |
Uptime: | 11:33:09 |
Calls: | 9,783 |
Calls today: | 2 |
Files: | 13,748 |
Messages: | 6,187,342 |