copy from remote location to another remote location through localhost

Hello!

There are 3 computers: A, B and C. To ssh (scp) from A to C (and from C
to A) one has to go through B. I want to copy a file from A to C in one
step. So I need something like:
scp --go-through-local-host userA [at] A:file.txt userB [at] B:

Is there such tool on the market?

TIA
--
jimmij
jimmij [ Mo, 21 Januar 2008 16:19 ] [ ID #1912860 ]

Re: copy from remote location to another remote location through localhost

On Mon, 21 Jan 2008 16:19:29 +0100, jimmij wrote:
> Hello!
>
> There are 3 computers: A, B and C. To ssh (scp) from A to C (and from C
> to A) one has to go through B. I want to copy a file from A to C in one
> step. So I need something like:
> scp --go-through-local-host userA [at] A:file.txt userB [at] B:
[...]

Not sure what you mean. What about something along those lines:

ssh userA [at] A 'gzip < file.txt' | ssh userB [at] B 'gunzip > file.txt'

--
Stephane
Stephane CHAZELAS [ Mo, 21 Januar 2008 16:31 ] [ ID #1912861 ]

Re: copy from remote location to another remote location throughlocalhost

Am Mon, 21 Jan 2008 16:19:29 +0100 schrieb jimmij:

> Hello!
>
> There are 3 computers: A, B and C. To ssh (scp) from A to C (and from C
> to A) one has to go through B. I want to copy a file from A to C in one
> step. So I need something like:
> scp --go-through-local-host userA [at] A:file.txt userB [at] B:
>
> Is there such tool on the market?
>
> TIA

netcat, but it also works with ssh and hostkeys
Burkhard Ott [ Mo, 21 Januar 2008 16:34 ] [ ID #1912862 ]

Re: copy from remote location to another remote location throughlocalhost

jimmij wrote:
> Hello!
>
> There are 3 computers: A, B and C. To ssh (scp) from A to C (and from C
> to A) one has to go through B. I want to copy a file from A to C in one
> step. So I need something like:
> scp --go-through-local-host userA [at] A:file.txt userB [at] B:
>
> Is there such tool on the market?
>
> TIA

ssh userA [at] A 'scp file.txt userC [at] C:'

-Wayne
wayne [ Mo, 21 Januar 2008 19:21 ] [ ID #1912866 ]

Re: copy from remote location to another remote location through localhost

jimmij <jimmij [at] jj.jj> writes:

> Hello!
>
> There are 3 computers: A, B and C. To ssh (scp) from A to C (and from C
> to A) one has to go through B. I want to copy a file from A to C in one
> step. So I need something like:
> scp --go-through-local-host userA [at] A:file.txt userB [at] B:

There is (of course) misprint. Should be
scp --go-through-local-host userA [at] A:file.txt userC [at] C:

(while I'm on B).

--
jimmij
jimmij [ Mo, 21 Januar 2008 19:34 ] [ ID #1912867 ]

Re: copy from remote location to another remote location throughlocalhost

On Mon, 21 Jan 2008 13:21:03 -0500, Wayne wrote:

> jimmij wrote:
>> Hello!
>>
>> There are 3 computers: A, B and C. To ssh (scp) from A to C (and from C
>> to A) one has to go through B. I want to copy a file from A to C in one
>> step. So I need something like:
>> scp --go-through-local-host userA [at] A:file.txt userB [at] B:
>>
>> Is there such tool on the market?
>>
>> TIA
>
> ssh userA [at] A 'scp file.txt userC [at] C:'
>
> -Wayne

This of course fails the OP's request that it goes through the local
machine (B).

Stephane's suggestion
ssh userA [at] A 'gzip < file.txt' | ssh userC [at] C 'gunzip > file.txt'
if better. However you need to see if ssh is already compressing the data
stream, and avoid doing so a second time. It also does not allow transfer
of the file attributes, e.g. owner and modification time. I would use

ssh userA [at] A 'tar cf - file.txt' | ssh userC [at] C 'tar xf -'

together with a sensible ~/.ssh/config file which set compression levels
in a manner that was appropriate. I might even use aliases for A and C if
this was something that I expected to do a lot of.
Icarus Sparry [ Mo, 21 Januar 2008 20:41 ] [ ID #1912868 ]

Re: copy from remote location to another remote location through

On 21 Gen, 20:41, Icarus Sparry <use... [at] icarus.freeuk.com> wrote:
> On Mon, 21 Jan 2008 13:21:03 -0500, Wayne wrote:
> > jimmij wrote:
> >> Hello!
>
> >> There are 3 computers: A, B and C. To ssh (scp) from A to C (and from C=

> >> to A) one has to go through B. I want to copy a file from A to C in one=

> >> step. So I need something like:
> >> scp --go-through-local-host userA [at] A:file.txt userB [at] B:
>
> >> Is there such tool on the market?
>
> >> TIA
>
> > ssh userA [at] A 'scp file.txt userC [at] C:'
>
> > -Wayne
>
> This of course fails the OP's request that it goes through the local
> machine (B).
>
> Stephane's suggestion
> =A0 =A0ssh userA [at] A 'gzip < file.txt' | ssh userC [at] C 'gunzip > file.txt'
> if better. However you need to see if ssh is already compressing the data
> stream, and avoid doing so a second time. It also does not allow transfer
> of the file attributes, e.g. owner and modification time. I would use
>
> ssh userA [at] A 'tar cf - file.txt' | ssh userC [at] C 'tar xf -'
>
> together with a sensible ~/.ssh/config file which set compression levels
> in a manner that was appropriate. I might even use aliases for A and C if
> this was something that I expected to do a lot of.

Netcat un both sides of A B C and is fast
remote side $nc -l -p 9000 > file;
local side-$ cat file |nc -w 3 ip 9000 ,as to in that way not sure but
give a probe
franzi [ Mo, 21 Januar 2008 23:23 ] [ ID #1912870 ]

Re: copy from remote location to another remote location through

On Mon, 21 Jan 2008 14:23:16 -0800, franzi wrote:

> On 21 Gen, 20:41, Icarus Sparry <use... [at] icarus.freeuk.com> wrote:
>> On Mon, 21 Jan 2008 13:21:03 -0500, Wayne wrote:
>> > jimmij wrote:
>> >> Hello!
>>
>> >> There are 3 computers: A, B and C. To ssh (scp) from A to C (and
>> >> from C to A) one has to go through B. I want to copy a file from A
>> >> to C in one step. So I need something like:
>> >> scp --go-through-local-host userA [at] A:file.txt userB [at] B:
>>
>> >> Is there such tool on the market?
>>
>> >> TIA
>>
>> > ssh userA [at] A 'scp file.txt userC [at] C:'
>>
>> > -Wayne
>>
>> This of course fails the OP's request that it goes through the local
>> machine (B).
>>
>> Stephane's suggestion
>>    ssh userA [at] A 'gzip < file.txt' | ssh userC [at] C 'gunzip > file.txt'
>> if better. However you need to see if ssh is already compressing the
>> data stream, and avoid doing so a second time. It also does not allow
>> transfer of the file attributes, e.g. owner and modification time. I
>> would use
>>
>> ssh userA [at] A 'tar cf - file.txt' | ssh userC [at] C 'tar xf -'
>>
>> together with a sensible ~/.ssh/config file which set compression
>> levels in a manner that was appropriate. I might even use aliases for A
>> and C if this was something that I expected to do a lot of.
>
> Netcat un both sides of A B C and is fast remote side
> $ nc -l -p 9000 > file;
> local side-
> $ cat file |nc -w 3 ip 9000 ,as to in that way not sure but
> give a probe

ssh will be as fast as netcat if no encryption is used. Depending on the
circumstances this may or may not be a good thing. It can however be
specified in the config file.

You left out the commands to run on host B
nc -l -p 9000 | nc -w 3 C 9000
and it would be helpful if you explained which address you ment when you
said "ip".
Icarus Sparry [ Mo, 21 Januar 2008 23:47 ] [ ID #1912872 ]

Re: copy from remote location to another remote location through localhost

jimmij <jimmij [at] jj.jj> writes:
>
>There are 3 computers: A, B and C. To ssh (scp) from A to C (and from C
>to A) one has to go through B. I want to copy a file from A to C in one
>step. So I need something like:
>scp --go-through-local-host userA [at] A:file.txt userB [at] B:
>
>Is there such tool on the market?
>

There used to be. UUCP

-Greg
--
::::::::::::: Greg Andrews ::::: gerg [at] panix.com :::::::::::::
I have a map of the United States that's actual size.
-- Steven Wright
gerg [ Di, 22 Januar 2008 02:21 ] [ ID #1913562 ]

Re: copy from remote location to another remote location throughlocalhost

jimmij wrote:
> jimmij <jimmij [at] jj.jj> writes:
>
>> Hello!
>>
>> There are 3 computers: A, B and C. To ssh (scp) from A to C (and from C
>> to A) one has to go through B. I want to copy a file from A to C in one
>> step. So I need something like:
>> scp --go-through-local-host userA [at] A:file.txt userB [at] B:
>
> There is (of course) misprint. Should be
> scp --go-through-local-host userA [at] A:file.txt userC [at] C:
>
> (while I'm on B).
>

That's what I thought you meant. Some of these other posters
think you want to transfer from A to A and then to C, but
of course what you wanted was, while on B, to instruct A to send
the files to C. Or instruct C to grab the files from A.
See my answer for a method to do this. (In the olden days
we used "uux" to run a "uucp" command from A to copy files to C.
This came up more often than you'd think!)

-Wayne
wayne [ Di, 22 Januar 2008 04:39 ] [ ID #1913565 ]

Re: copy from remote location to another remote location throughlocalhost

Icarus Sparry wrote:
>>> There are 3 computers: A, B and C. To ssh (scp) from A to C (and from C
>>> to A) one has to go through B. I want to copy a file from A to C in one
>>> step. So I need something like:
>>> scp --go-through-local-host userA [at] A:file.txt userB [at] B:
>>>
>>> Is there such tool on the market?
>>>
>>> TIA
>> ssh userA [at] A 'scp file.txt userC [at] C:'
>>
>> -Wayne
>
> This of course fails the OP's request that it goes through the local
> machine (B).

I think you mis-understood the OP. That wasn't his request, that
was his problem that he wanted to avoid.


-Wayne
wayne [ Di, 22 Januar 2008 04:41 ] [ ID #1913566 ]

Re: copy from remote location to another remote location through

On 22 Gen, 04:41, Wayne <nos... [at] all4me.invalid> wrote:
> Icarus Sparry wrote:
> >>> There are 3 computers: A, B and C. To ssh (scp) from A to C (and from =
C
> >>> to A) one has to go through B. I want to copy a file from A to C in on=
e
> >>> step. So I need something like:
> >>> scp --go-through-local-host userA [at] A:file.txt userB [at] B:
>
> >>> Is there such tool on the market?
>
> >>> TIA
> >> ssh userA [at] A 'scp file.txt userC [at] C:'
>
> >> -Wayne
>
> > This of course fails the OP's request that it goes through the local
> > machine (B).
>
> I think you mis-understood the OP. =A0That wasn't his request, that
> was his problem that he wanted to avoid.
>
> -Wayne

If i'm right jimmij said
I want to copy a file from A to C in one step
but do you have accsess to C,if not,i do not know how is that
possible,and you want to view all the data that run through B,is that
right?
the only way, i can immagine is ssh,but for sure there are othere
methode,let me know,
a part hacking style
franzi [ Di, 22 Januar 2008 09:43 ] [ ID #1913568 ]

Re: copy from remote location to another remote location through localhost

franzi <hazzino [at] gmail.com> writes:

>> >> ssh userA [at] A 'scp file.txt userC [at] C:'
>>
>> >> -Wayne
>>
>> > This of course fails the OP's request that it goes through the local
>> > machine (B).
>>
>> I think you mis-understood the OP.  That wasn't his request, that
>> was his problem that he wanted to avoid.
>>
>> -Wayne
>
> If i'm right jimmij said
> I want to copy a file from A to C in one step
> but do you have accsess to C,if not,i do not know how is that
> possible,and you want to view all the data that run through B,is that
> right?
> the only way, i can immagine is ssh,but for sure there are othere
> methode,let me know,
> a part hacking style

A lot of confusion...

1. B is a firewall.
2. To reach A from C (and vice versa) first I have to go to B.
3. Up to now to copy from A to C I first copied from A to B, and then
from B to C (being all the time on B).

Hope that is clear right now.

ps. Wayne solution doesn't work for me.

--
jimmij
jimmij [ Di, 22 Januar 2008 14:17 ] [ ID #1913573 ]

Re: copy from remote location to another remote location through localhost

Wayne <nospam [at] all4me.invalid> writes:

>> scp --go-through-local-host userA [at] A:file.txt userC [at] C:
>> (while I'm on B).
>>
>
> That's what I thought you meant. Some of these other posters
> think you want to transfer from A to A and then to C, but
> of course what you wanted was, while on B, to instruct A to send
> the files to C. Or instruct C to grab the files from A.
> See my answer for a method to do this.

Your solution doesn't work. Please note, that I want to send from A to C
via B (localhost). B is a firewall and I cannot scp from A to C
directly.

--
jimmij
jimmij [ Di, 22 Januar 2008 14:20 ] [ ID #1913574 ]

Re: copy from remote location to another remote location through localhost

gerg [at] panix.com (Greg Andrews) writes:

> There used to be. UUCP

man uucp sounds promising, but it is not available on the system (and I'm
not admistrator on any of those systems).

--
jimmij
jimmij [ Di, 22 Januar 2008 14:27 ] [ ID #1913575 ]

Re: copy from remote location to another remote location through localhost

On Tue, 22 Jan 2008 14:17:34 +0100, jimmij wrote:

> franzi <hazzino [at] gmail.com> writes:
>
>>> >> ssh userA [at] A 'scp file.txt userC [at] C:'
>>>
>>> >> -Wayne
>>>
>>> > This of course fails the OP's request that it goes through the local
>>> > machine (B).
>>>
>>> I think you mis-understood the OP.  That wasn't his request, that was
>>> his problem that he wanted to avoid.
>>>
>>> -Wayne

The OP has clarified the original request and it appears that I had
correctly interpreted what he wanted.

>> If i'm right jimmij said
>> I want to copy a file from A to C in one step but do you have accsess
>> to C,if not,i do not know how is that possible,and you want to view all
>> the data that run through B,is that right?
>> the only way, i can immagine is ssh,but for sure there are othere
>> methode,let me know,
>> a part hacking style
>
> A lot of confusion...
>
> 1. B is a firewall.
> 2. To reach A from C (and vice versa) first I have to go to B. 3. Up to
> now to copy from A to C I first copied from A to B, and then from B to C
> (being all the time on B).
>
> Hope that is clear right now.
>
> ps. Wayne solution doesn't work for me.

Does the solution that Stephane & I suggest work (on the firewall run ssh
A "tar cf - file" | ssh C "tar xf -").
Icarus Sparry [ Di, 22 Januar 2008 15:20 ] [ ID #1913578 ]

Re: copy from remote location to another remote location through localhost

On Tue, 22 Jan 2008 14:20:54 +0100, jimmij wrote:
> Wayne <nospam [at] all4me.invalid> writes:
>
>>> scp --go-through-local-host userA [at] A:file.txt userC [at] C:
>>> (while I'm on B).
>>>
>>
>> That's what I thought you meant. Some of these other posters
>> think you want to transfer from A to A and then to C, but
>> of course what you wanted was, while on B, to instruct A to send
>> the files to C. Or instruct C to grab the files from A.
>> See my answer for a method to do this.
>
> Your solution doesn't work. Please note, that I want to send from A to C
> via B (localhost). B is a firewall and I cannot scp from A to C
> directly.

Looks like:

ssh -o Compression=yes userA [at] A 'tar cf - file.txt' |
ssh -o Compression=yes userC [at] C 'tar xpf -'

(from B) as suggested by Icarus would work for you.

Or from C:

ssh userB [at] B 'ssh userA [at] A "tar cf - file.txt"' | tar xpf -

(add the compression option if need be).

(this assumes that you have your keys configured properly so
that no passwd is asked).

--
Stephane
Stephane CHAZELAS [ Di, 22 Januar 2008 15:46 ] [ ID #1913580 ]

Re: copy from remote location to another remote location through localhost

Icarus Sparry <usenet [at] icarus.freeuk.com> writes:

> Does the solution that Stephane & I suggest work (on the firewall run ssh
> A "tar cf - file" | ssh C "tar xf -").

Yes, it does.
But as a perfectionist I somehow don't like to use external commands ;)

--
jimmij
jimmij [ Di, 22 Januar 2008 15:54 ] [ ID #1913582 ]

Re: copy from remote location to another remote location through localhost

On Tue, 22 Jan 2008 15:54:36 +0100, jimmij wrote:
> Icarus Sparry <usenet [at] icarus.freeuk.com> writes:
>
>> Does the solution that Stephane & I suggest work (on the firewall run ssh
>> A "tar cf - file" | ssh C "tar xf -").
>
> Yes, it does.
> But as a perfectionist I somehow don't like to use external commands ;)
[...]

External to what? What do you think scp, sshd are internal to?

--
Stephane
Stephane CHAZELAS [ Di, 22 Januar 2008 16:00 ] [ ID #1913584 ]

Re: copy from remote location to another remote location through localhost

Stephane Chazelas <stephane_chazelas [at] yahoo.fr> writes:

> On Tue, 22 Jan 2008 14:20:54 +0100, jimmij wrote:
>> Wayne <nospam [at] all4me.invalid> writes:
>>
>>>> scp --go-through-local-host userA [at] A:file.txt userC [at] C:
>>>> (while I'm on B).
>>>>
>>>
>>> That's what I thought you meant. Some of these other posters
>>> think you want to transfer from A to A and then to C, but
>>> of course what you wanted was, while on B, to instruct A to send
>>> the files to C. Or instruct C to grab the files from A.
>>> See my answer for a method to do this.
>>
>> Your solution doesn't work. Please note, that I want to send from A to C
>> via B (localhost). B is a firewall and I cannot scp from A to C
>> directly.
>
> Looks like:
>
> ssh -o Compression=yes userA [at] A 'tar cf - file.txt' |
> ssh -o Compression=yes userC [at] C 'tar xpf -'

The data is compressed and decompressed twice. Better would be:

ssh -o Compression=no userA [at] A 'tar cf - file.txt | gzip -9' |
ssh -o Compression=no userC [at] C 'gzip -d | tar xpf -'

as it compresses data only one time.

--
Best regards, _ _
.o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--
Michal Nazarewicz [ Mi, 23 Januar 2008 22:23 ] [ ID #1914227 ]
Linux » comp.unix.shell » copy from remote location to another remote location through localhost

Vorheriges Thema: internal alias
Nächstes Thema: How can I create test data which mirrors real life?