Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

then

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.

share|improve this question
up vote 5 down vote accepted

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.

share|improve this answer
    
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 '11 at 21:11
    
@Tommy: For a single file? See update. Or just remove the z option from both ends. – grawity Sep 15 '11 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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .