The following command is working as expected.
ssh [email protected] "ssh [email protected] 'cat test.txt'" > /home/shantanu/test.txt
What I need to do is to copy the entire directory instead of a single file.
Is it possible to use rync with SSH tunneling?
You can use
scp
to copy single or multiple files and also usersync
with an ssh transport:and
Both programs also work the other way round, with the remote part as the origin and the local as the destination.
See
man scp
andman rsync
.Edit
If you indeed need an intermediate server, you could use ssh port forwarding:
In one shell, use this command to establish a port forwarding:
This connects port 10022 on your local machine with port 22 on
10.199.199.91
, but won't open a shell, instead just blocks until you terminate it.Afterwards, on another shell/xterm, you can use either
but have to be aware that
soak@localhost
actually points to[email protected]
when entering your credentials.Edit 2, now featuring rsync
As you specifically asked about rsync, here is how to use rsync instead of scp. It requires the same port forwarding enabled as the
scp
variant:and again remember that you are actually connecting to
[email protected]
.You could pipe tar.
eg.
Another way is use SSH Port Forwarding.
First, run the following command on your computer:
This allocated a socket to listen to port 2302 on localhost. Whenever a connection connect to this port, it will be forwarded to
10.199.199.191:22
.So you can copy a folder on
10.199.199.191
to your machine with:Also available is ssh's ProxyCommand.
From Undeadly: