When the rsync program is invoked over ssh what does the interaction between rsync and ssh look like? What feature of ssh is rsync using? I am interested in the interaction between rsync and ssh.
SSH – How does rysnc work over ssh
rsyncssh
rsyncssh
When the rsync program is invoked over ssh what does the interaction between rsync and ssh look like? What feature of ssh is rsync using? I am interested in the interaction between rsync and ssh.
Best Answer
ssh
provides a connected stream from the local system running yourrsync
to another instance running on the remote server. The localrsync
starts it as part of thessh
connection process - it is not the same instance ofrsync
that might be running as a daemon on that remote server.What is an ssh stream?
An ssh stream is what you use when you
ssh
to a remote system. You might prefer to call it an ssh session. That's fine. As an example,ssh snow@grumpy.example.net
would connect you to that remote system and give you an interactive session. Anything you typed locally would be received and actioned remotely, and anything generated remotely would be presented to you locally.Similarly,
ssh -t snow@doc.example.net vi /etc/hosts
would set up a connection to runvi /etc/hosts
on the remote system as if you were using it locally. (The-t
flag tellsssh
to ensure that the remote command,vi
, is run on a pseudo-terminal; otherwise it would skip that layer of complexity.)Now, for
rsync
, the connection is set up by the local instance with something likessh snow@bashful.example.net rsync --server -nlogDtpre.iLsf {local_path} {remote_path}
. This allows the localrsync
to talk with the remotersync
over a connection just like you would use to access that same remote server. The remote instance ofrsync
knows it's a server because of the flags it has been provided when started by the local instance.You can see how
rsync
has been called remotely by running something likessh snow@dopey.example.net 'ps -ef | grep [r]sync'
while thersync
is in progress.Why not just have
rsync
talk directly withoutssh
?The advantage of using
ssh
is twofoldrsync
would either have to implement its own encryption or ignore the issue. Both are hazardous in today's Internet connected world.