scp between two remote hosts
Peter Watkins
peterw at usa.net
Sat Jan 19 03:46:48 EST 2002
On Fri, Jan 18, 2002 at 03:53:58PM -0000, Shih, Robert wrote:
> I am running openssh (OpenSSH_2.9p1, SSH protocols 1.5/2.0). The scenario
> is that I have got three machines (A, B and C). The sshd on host A is
> listensing on port 1234, and the sshd on host B is listensing on port 5678.
> How can I set up a scp from a third host C so as to copy a file from host A
> to host B?
You'll have to be creative, I think.
> scp -P 1234 myname at A:/var/tmp/file1 -P 5678 myname at B:/var/tmp/file1
ssh -p 1234 myname at A "scp -P 5678 /var/tmp/file1 myname at B:/var/tmp/file1"
You'd probably need to use keypair, shosts, etc. to authenticate A -> B.
ssh -p 1234 myname at A "cat /var/tmp/file1" | ssh -p 5678 myname at B "cat > /var/tmp/file1"
I think either of those tricks would work. The first is more efficient, as
the data only crosses the network once, but authentication may be sticky; it
doesn't work for me if A -> B needs interactive password authentication.
The second is more likely to work easily, but the file had to go through
A -> C and C -> B, which is a waste of bandwidth, and might not work, as
you never said whether C could communicate directly with B.
The second trick definitely works, though with my 2.5.2p2 systems, using
password auth for both C -> A and C -> B connections, my terminal prompts me
for both passwords on the same line. I enter one, press return, and then the
other, ad pres return. The second password I type is echoed to my screen.
Oops. Maybe someone could try that with the latest release and/or CVS?
-Peter
More information about the openssh-unix-dev
mailing list