Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

7 May, 2024: fms is rebuilding. Don't expect much in that section for quite a few days, maybe longer.
Also, overboard does not work right now. If I knew why, I'd fix it!


devel / comp.unix.shell / scp: ambiguous target

SubjectAuthor
* scp: ambiguous targetKenny McCormack
+* Re: scp: ambiguous targetHelmut Waitzmann
|`* Re: scp: ambiguous targetKenny McCormack
| `- Re: scp: ambiguous targetHelmut Waitzmann
+- Re: scp: ambiguous targetS.K.R. de Jong
`* Re: scp: ambiguous targetKaz Kylheku
 `* Re: scp: ambiguous targetWilliam Ahern
  `- Re: scp: ambiguous targetKenny McCormack

1
scp: ambiguous target

<tcbek0$3l8qs$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=5448&group=comp.unix.shell#5448

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: scp: ambiguous target
Date: Tue, 2 Aug 2022 15:07:44 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <tcbek0$3l8qs$1@news.xmission.com>
Injection-Date: Tue, 2 Aug 2022 15:07:44 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3842908"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Tue, 2 Aug 2022 15:07 UTC

$ 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.

Note: I cleaned this up a bit for posting. If you have trouble replicating
the error, let me know, and I'll make a suggestion as to what to try next.

--
Modern Christian: Someone who can take time out from using Leviticus
to defend homophobia and Exodus to plaster the Ten Commandments on
every school and courthouse to claim that the Old Testament is merely
"ancient laws" that "only applies to Jews".

Re: scp: ambiguous target

<83wnbqd5ol.fsf@helmutwaitzmann.news.arcor.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=5449&group=comp.unix.shell#5449

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!uk09UeDaRdwcQv5zMWLmSQ.user.46.165.242.75.POSTED!not-for-mail
From: nn.throttle@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: scp: ambiguous target
Date: Tue, 02 Aug 2022 17:30:02 +0200
Organization: Aioe.org NNTP Server
Message-ID: <83wnbqd5ol.fsf@helmutwaitzmann.news.arcor.de>
References: <tcbek0$3l8qs$1@news.xmission.com>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: gioia.aioe.org; logging-data="29198"; posting-host="uk09UeDaRdwcQv5zMWLmSQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Cancel-Lock: sha1:MkIOhvdyA0yEqBDHa3f28qDeHio=
X-Notice: Filtered by postfilter v. 0.9.2
Mail-Copies-To: nobody
 by: Helmut Waitzmann - Tue, 2 Aug 2022 15:30 UTC

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?

Re: scp: ambiguous target

<tcbi42$3lap3$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=5450&group=comp.unix.shell#5450

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: scp: ambiguous target
Date: Tue, 2 Aug 2022 16:07:30 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <tcbi42$3lap3$1@news.xmission.com>
References: <tcbek0$3l8qs$1@news.xmission.com> <83wnbqd5ol.fsf@helmutwaitzmann.news.arcor.de>
Injection-Date: Tue, 2 Aug 2022 16:07:30 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3844899"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Tue, 2 Aug 2022 16:07 UTC

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.

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/FreeCollege

Re: scp: ambiguous target

<83bkt2d0ib.fsf@helmutwaitzmann.news.arcor.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=5451&group=comp.unix.shell#5451

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!uk09UeDaRdwcQv5zMWLmSQ.user.46.165.242.75.POSTED!not-for-mail
From: nn.throttle@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: scp: ambiguous target
Date: Tue, 02 Aug 2022 19:21:48 +0200
Organization: Aioe.org NNTP Server
Message-ID: <83bkt2d0ib.fsf@helmutwaitzmann.news.arcor.de>
References: <tcbek0$3l8qs$1@news.xmission.com>
<83wnbqd5ol.fsf@helmutwaitzmann.news.arcor.de>
<tcbi42$3lap3$1@news.xmission.com>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Info: gioia.aioe.org; logging-data="1488"; posting-host="uk09UeDaRdwcQv5zMWLmSQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Cancel-Lock: sha1:gOk01H+vEl7RrqLIRUIcG/GRXJg=
Mail-Copies-To: nobody
X-Notice: Filtered by postfilter v. 0.9.2
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
 by: Helmut Waitzmann - Tue, 2 Aug 2022 17:21 UTC

gazelle@shell.xmission.com (Kenny McCormack):
>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) -
>

The problem with "should work as is" is, that "scp" (via "ssh")
doesn't and cannot know anything about the shell running at the
remote system:  The shell there might be a POSIX compliant shell, a
"csh", "tcsh", "fish", "ksh", Bourne shell, Microsoft power
shell(?), …

Therefore "scp" doesn't know how to quote for the remote shell
command line.

>or at least be documented.
>

Yes.  That would enable the "scp" invoker (i. e. you and me), who
knows the remote system, how to do proper quoting for the shell
remote command line.

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

That's why I refrain from using "scp" at all.  I prefer to start a
"tar" command at the local and (via "ssh") at the remote site and
send the tape archive via stdout/stdin to have it instantly created
and extracted.  I would do something like

tar cf - .profile |
ssh -- "$remote_account" "$(
my_quote_words_for_shells tar xpf -
)"

when knowing that a POSIX compliant shell is running at the remote
site, whereas "my_quote_words_for_shells" quotes its given arguments
according to the quoting rules for a POSIX compliant shell,
concatenates them using spaces to be used as a (part of a) command
line, and sends the result to stdout.

If the local and remote shells both are "bash", one can use

printf ' %q' tar xpf -

rather than

my_quote_words_for_shells tar xpf -

Re: scp: ambiguous target

<tcbovk$ubf$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=5452&group=comp.unix.shell#5452

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!fs4vz7lwhQCwq5L3H1slGg.user.46.165.242.75.POSTED!not-for-mail
From: SKRdJ@nowhere.net (S.K.R. de Jong)
Newsgroups: comp.unix.shell
Subject: Re: scp: ambiguous target
Date: Tue, 2 Aug 2022 18:04:36 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <tcbovk$ubf$1@gioia.aioe.org>
References: <tcbek0$3l8qs$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="31087"; posting-host="fs4vz7lwhQCwq5L3H1slGg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Pan/0.149 (Bellevue; 4c157ba git@gitlab.gnome.org:GNOME/pan.git)
X-Notice: Filtered by postfilter v. 0.9.2
 by: S.K.R. de Jong - Tue, 2 Aug 2022 18:04 UTC

On Tue, 2 Aug 2022 15:07:44 -0000 (UTC), Kenny McCormack 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.

Have you tried

scp -p .profile localhost:"this\ is\ a\ test"

?

Re: scp: ambiguous target

<20220802113852.483@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=5457&group=comp.unix.shell#5457

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: 480-992-1380@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: scp: ambiguous target
Date: Tue, 2 Aug 2022 18:59:58 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 81
Message-ID: <20220802113852.483@kylheku.com>
References: <tcbek0$3l8qs$1@news.xmission.com>
Injection-Date: Tue, 2 Aug 2022 18:59:58 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="6743b589a64f2dc7b5fa4f75edd972dc";
logging-data="1765970"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hPOgttIi4VciFoT32UqzYQfiq14PvAG8="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:5mGvPJtMXsne/cbAbz3NotNaaFY=
 by: Kaz Kylheku - Tue, 2 Aug 2022 18:59 UTC

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

the filename is a combination of something passed on the command
line and in the protoco.

The receiving end can be unit-tested by echoing data to its stdin,
and the following example is presented:

$ rm -f /tmp/test
$ { echo C0644 6 test; printf "hello\\n"; } | scp -t /tmp
[ .. snip progress output ...]
$ cat /tmp/test
hello

The name of the file created by the receiving "scp -t" is a
combination of the -t argument, and the filename given in
the protocol by the "C0644 6 test" line.

The C protocol packet seems like it might be able to handle spaces.

I wonder whether the scp client couldn't just use / as the
-t argument and give a full path relativce to / in
in the C packet. (Or do the names in the packet have to be
simple base names with no slashes?)

The protocol also has commands for creating directories recursively;
Perhaps the scp client could be hacked to always uses that facility
under the hood even for what look like single file transfers.

Proof of concept:

Create the directory with spaces:

$ mkdir 'dir with spaces'

Now use the directory D protocol command to pretend we are recursively
copying a directory called 'dir with spaces', which contains a file
called 'test'. We pipe these commands to the remote scp command using
the ssh command (not using scp locally):

$ ( echo 'D0755 0 dir with spaces' ; echo C0644 6 test; printf 'hello\n'; echo E ) | ssh localhost scp -rt .
kaz@localhost's password:

OK, the result:

$ ls -l dir\ with\ spaces/
total 4
-rw-r--r-- 1 kaz kaz 6 Aug 2 11:53 test
$ cat dir\ with\ spaces/test
hello

So to reap instead of remotely executing "scp -t dir with spaces" and
then using a "C 0644 6 test" comamnd to do a single file, we remotely
execute "scp -t ." and follow the directory D workflow with a nested
file C in it.

I'm guessing that for a path path like 'a b/c d/e f/f', you have to
parse that and issue multiple nested D comands for "a b", "c d", and
"e f", and end each one with a corresponding E; i.e. taht the protocol
D command will not do a "mkdir -p" type operation to create all the
needed path components. Maybe it does, though?

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: scp: ambiguous target

<95kori-2o82.ln1@wilbur.25thandClement.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=5459&group=comp.unix.shell#5459

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 02 Aug 2022 22:14:50 +0000
Message-ID: <95kori-2o82.ln1@wilbur.25thandClement.com>
From: william@25thandClement.com (William Ahern)
Subject: Re: scp: ambiguous target
Newsgroups: comp.unix.shell
References: <tcbek0$3l8qs$1@news.xmission.com> <20220802113852.483@kylheku.com>
User-Agent: tin/2.4.4-20191224 ("Millburn") (OpenBSD/7.1 (amd64))
Date: Tue, 2 Aug 2022 15:13:29 -0700
Lines: 33
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-Xvxe9JVlB8mTjtJnUnMP7n3x8FElilMD2jVU9yPma9KSG73KA6QRqmJ9D4z5/G20xo9rIKOcoVt8S/c!In+g+sentuV3otCF2eFJs6IrZQX/j9F9q5Fh3WiNmbuONYpjkGgFsBLpStmhE2ygkbM=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: William Ahern - Tue, 2 Aug 2022 22:13 UTC

Kaz Kylheku <480-992-1380@kylheku.com> wrote:
> 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

Re: scp: ambiguous target

<tccmob$3luv1$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=5463&group=comp.unix.shell#5463

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: scp: ambiguous target
Date: Wed, 3 Aug 2022 02:32:43 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <tccmob$3luv1$1@news.xmission.com>
References: <tcbek0$3l8qs$1@news.xmission.com> <20220802113852.483@kylheku.com> <95kori-2o82.ln1@wilbur.25thandClement.com>
Injection-Date: Wed, 3 Aug 2022 02:32:43 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3865569"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Wed, 3 Aug 2022 02:32 UTC

In article <95kori-2o82.ln1@wilbur.25thandClement.com>,
William Ahern <william@25thandClement.com> wrote:
....
>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.

Yeah. That's what I would have expected. That it would "just work" and
not need to spawn a shell - with all the "finickiness" that that entails.

>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

I wonder when Debian will make this switch...

--
People who want to share their religious views with you
almost never want you to share yours with them. -- Dave Barry

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor