Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to copy some files from remote machine at work, but I can't ssh to the machine directly,

I login via an SSH proxy which presents menu of hosts to connect too, I choose the machine I want and then login with my password.

Is there a way with SCP or SSH or some other means to be able to copy files from the remote to my local host?

share|improve this question

migrated from stackoverflow.com Jan 10 '10 at 8:14

This question came from our site for professional and enthusiast programmers.

2 Answers 2

Assuming both hops use SSH, you can use port forwarding to tunnel SSH inside of the outside hop's SSH and access the internal network directly.

Host MAKESOCKS.internal-network
HostName ssh-gate.internal-network
DynamicForward localhost:10022

Host *.internal-network
ProxyCommand connect -S %h %p

Use it like this:

ssh -f -N MAKESOCKS.internal-network
ssh host.internal-network

The connect command is in the connect-proxy package on Debian/Ubuntu.

share|improve this answer

Assuming your remote host is called example.com, you can setup a 'master' ssh connection like so

ssh -Mt -S /tmp/ssh user@example.com

Then you can piggy back your scp over this like so

scp -o "ControlPath /tmp/ssh" <src_file> user@example.com:/<target_file>

Edit : Ah. I didn't read your question properly. You were connecting via a separate proxy. In that case, the port forwarding technique suggested in the other answer would be more appropriate.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.