I have a problem about transferring files between hosts. Lab environment is like:

My host <-> Host A <-> Host B

I only have access to Host A and I want to transfer files to Host B. Host A has access to Host B.

I want to use scp to transfer file from my host to Host B directly.

I have tried ssh -L :8899:<host-B>:22 user@host-a and scp -P 8899 myfile.txt user@localhost:/path/to/store/files. But failed :(

channel 2: open failed: administratively prohibited: open failed ssh_exchange_identification: Connection closed by remote host lost connection

How can I realize this job?

Note: When I ssh to Host A, I have to input password generated by a RSA token. Is this the reason why I got error message ?


The ssh -L syntax with the ports you've listed would be: ssh -L 8899:<Host B>:22 user@<Host A>

This would listen on port 8899 on , and anything it receives will be forwarded via ssh to and from there sent to in the clear. will think it's communicating with something running on

I'm not sure how this would help you.

You can chain up ssh sessions using PoxyCommand, thus:

Host Host-B
  HostName      Host-B.some.private.network.domain
  ProxyCommand          ssh -q Host-A nc %h %p

If this is in your .ssh/config file, typing scp blah.txt <Host-B>: will try to send file blah.txt through an ssh session to Host-A and from there to Host-B, all via ssh.

You ssh client will on will act as though it's connecting directly to Host-B. Any prompts for RSA keys etc will come back down the ssh session as if you were sitting on Host-A.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.