Skip to content
Advertisement

Circular SSH Tunnel

Is is possible to create a circular SSH Tunnel?

local1 >SSH_TUNNEL> remote1 >SSH_TUNNEL> local1

On “Remote1” I create a TAR that I want to pipe to STDOUT ( – ) … can I then TAR – . | >SSH_TUNNEL> local1

ssh user@remote1 "tar -cvf - . | ssh user@local1"

I’ve googled and forum’d and googled some more … I can’t seem to find the answer. Also, I did find references like this:

SSH Tunnel Complex

But it has low votes and the owner didn’t mark it as correct … I’m not even sure if that applies to my issue.

Any ideas and/or suggestions are welcome!

Thanks!

Advertisement

Answer

Yes, you can, and I know why you might want to do this. The listed command is rather silly, but still …

ssh -R2222:127.0.0.1:22 user@remote1 "tar -cvf - . | ssh user@local1:2222 (whatever)"

If you do this more than once you will have public key headaches to cleanup. I don’t know any good way around this save editing .ssh/known_hosts every time.

The listed objective is better achieved as

ssh user@remote1 "tar -cvf - ." | (whatever)
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement