0

I'm on a vpn. I ssh to a machine through another machine like so

ssh -A -t -l bob 192.16.4.9 ssh -A -t node-17

I now need to scp a file from node-17:/tmp/something.

How can I do the above in one step? There is no space left on the other nodes to move it to first. I should add that public keys are used to authenticate between 192.168.4.9 and node-17

Thanks

0

I'm not sure about the -t options, but what I think you want is

ssh -At -o 'ProxyCommand ssh -At -l bob 192.16.4.9' node-17

Then the same method works with scp, e.g.

scp -o 'ProxyCommand ssh -At -l bob 192.16.4.9' file node-17:file

To make this connection configuration permanent so you don't have to reenter it every time, put the following into your ~/.ssh/config:

Host node-17
ProxyCommand ssh -At -l bob 192.16.4.9

Then all you'll need to run is ssh -At node-17 or scp file node-17:file.

0

Instead of SCP you could just cat the file on the remote machine and save the output locally.

ssh -A -t -l bob 192.16.4.9 ssh -A -t node-17 cat /tmp/something > /local/copy/of/something

You can also use this in the other direction to upload a file to the remote machine, but with an extra hop it requires some creative quoting on the command line:

ssh -A -t -l bob 192.16.4.9 'ssh -A -t node-17 "cat > /tmp/new-file"' < /local/copy/of/new-file

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.