Wednesday, February 7, 2018

SCP files thru multiple proxy hosts

I realize this might be old-hat for quite a few but I just learned it and this will save me so bloody much time!

While there are multiple ways of doing this.. including editing your .ssh/config file to include a similar reference I am choosing the full CLI method.

So first off make sure netcat (nc) is installed on all hosts.  Then craft a string as such:

scp -o ProxyCommand="ssh first_host nc second_host 22" /local/path/to/file user@target_host:/dest/path


So what I have done here is to ssh proxy through host1, to host2 then scp'd from host2 to target_host.  Which in my case was exactly what I needed since this new Java environment requires me to jump through two proxies to reach my target.

Like I said I know this is old stuff to a large percentage of you Unix/Linux admins but hopefully this will help someone.

No comments:

Post a Comment