Friday, May 15, 2009

SCP through a gateway


A serious break of my usual blog posts. I just wanted to keep these commands somewhere and I though the blog might be a good place. It's also a friendly remember that I'm a geek after all !

These two commands will allow you to directly connect to a host more than one machine away. At work we have a "proxy" (or gateway) machine that allows us to connect to the other servers on the network. Took me some time to find this command line on G. This way I can copy files on the remote server quickly !

scp -Cp -o "ProxyCommand ssh gatewayuser@gateway nc remotehost 22" remoteuser@remotehost:/some/where/file file_copy

rsync -rvc -e 'ssh -CA gatewayuser@gatewaymachine ssh' myDir/ remoteuser@remotemachine:/some/where/myDir/

Another interesting way for more permanent mount is to use fuse-sshfs and create a tunnel using SSH. You can create the tunnel with a command like such :
ssh -l user -vL 9022:remotemachine:22 gatewaymachine cat -

For the non-tech-savy reader who managed to get to this paragraph, I'll try to update soon with some more spring beauty pictures !

No comments: