I need to copy a file from a computer I can only access via SSHing into an intermediate computer.

Home -> server.com -> cluster.com

I'm trying to copy from cluster.com to home. I can ssh from home but not to home. The connection

server.com-> cluster.com

has an RSA public key but server will not allow

Home -> server RSA public key.

I've tried

home$ ssh server.com -L 2000:final:22 -N

which gave

channel 2: open failed: administratively prohibited: open failed

I've also tried

ssh -fN -L 4567:cluster.com:22 server.com


ssh cluster.com -L 2000:final:22 -N

which resulted in.

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

I got these ideas from scp files via intermediate host and Must I sftp to an intermediate server?

but can't seem to get the results to work, some of the other examples in the first link I can't follow so have only tried the ones I can. I never seem to be able to get ssh to do what I want.

Any help would be appreciated.

2 Answers 2


The SSH server on server.com is configured to refuse all TCP forwarding attempts through it; using -L will not work.

An alternative to SFTP and SCP is good old tar:

ssh server.com "ssh cluster.com \"cd mydir && tar cz myfile\"" | tar xvz

Or cat:

ssh server.com "ssh cluster.com \"cat mydir/myfile\"" | pv > myfile

The "| pv" part is optional; it causes a nice progress bar to be displayed if you have the pv program installed.

  • Thanks, all.txt is a test file, the file I ultimately want to copy is a large (5 gig) tar.bzip file dose that matter that its already tared up?
    – Tommy
    Sep 15, 2011 at 21:11
  • @Tommy: For a single file? See update. Or just remove the z option from both ends.
    – user1686
    Sep 15, 2011 at 21:22

It worked for me by adding a "-t" option: ssh -t server.com "ssh cluster.com \"cat mydir/myfile\""

Since I have a .pem key i use to connect to server.com, and a password to connect to cluster.com, i had to insert another -i before the -t to point to the .pem file.

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.