Re: scp via a intermediate computer



Peng Yu wrote:
Hi,

For some reason, I can only access computer A through computer B. That
is, suppose my computer is C, I can ssh to B from C, but I can not ssh
to A from C. Once I login computer B, I can ssh to A from B.

I'm wondering how to use port forwarding on B such that I can scp from
A to C. Otherwise, I'll have to scp files from A to B and then B to C,
which is too annoying.

Would you please let me know the command so that I can scp A to C
without creating any temporary files on B?

Thanks,
Peng

assuming your ssh daemons listen on port 22

1. choose an unused tcp port on B, say 1111
2. on A: ssh -nR 1111:C:22 B &
this sets up port forwarding from B:1111 to C:22, you need this once.
it tells you the pid on startup, you can kill the process once you don't need the forwarding anymore
note that B must be able to resolve the hostname "C" to an IP address
3. now on A: scp -P 1111 something B:
your scp now connects to B:1111 which has been forwarded to C:22

step 3 might need an "-o stricthostkeychecking=no" since scp believes it is connecting to B but through the forwarding is actually talking to C, which should have a different host key.

Regards
Joachim
.



Relevant Pages

  • Port Forwarding over Unreliable Connections
    ... I make extensive use of ssh port forwarding to access machines behind ... patiently wait a long time before finally snipping the connection. ...
    (comp.security.ssh)
  • Re: scp via a intermediate computer
    ... is, suppose my computer is C, I can ssh to B from C, but I can not ssh ... I'm wondering how to use port forwarding on B such that I can scp from ... Otherwise, I'll have to scp files from A to B and then B to C, ...
    (comp.security.ssh)
  • Re: Agent Forwarding Question for the list
    ... your e-mail doesn't appear to be about port forwarding at all... ... someuser@server1> ssh otheruser@server2 ... people are connecting to from that machine (where you made the config ...
    (SSH)
  • Re: scp via a intermediate computer
    ... is, suppose my computer is C, I can ssh to B from C, but I can not ssh ... I'm wondering how to use port forwarding on B such that I can scp from ... Otherwise, I'll have to scp files from A to B and then B to C, ... ssh: connect to host B 1111: Connection refused ...
    (comp.security.ssh)
  • Re: scp via a intermediate computer
    ... is, suppose my computer is C, I can ssh to B from C, but I can not ssh ... I'm wondering how to use port forwarding on B such that I can scp from ... Otherwise, I'll have to scp files from A to B and then B to C, ... Now enter the password for B. Leave the connection open. ...
    (comp.security.ssh)