30

I always used to use the following command when copying from a server:

rsync --progress -avze ssh user@host:/path/to/files ./here

However, a friend of mine showed me that I can simply do:

rsync --progress -avz user@host:/path/to/files ./here

So the question is, if you do not need -e ssh why is it there anyways?

5 Answers 5

29

Any time you need additional options to the ssh command outside of the user and host, then you need the -e flag. Perhaps the server you're connecting to has ssh listening on port 2222.

rsync -e 'ssh -p 2222' /source usr@host:/dest

An alternative to getting around this, there are 2 files you can use. /etc/ssh/ssh_config or ~/.ssh/config

The config file uses the same format as ssh_config. It's just able to be configured on a per user basis!

3
  • 1
    Slightly off-topic, but is there any reason to use /etc/ssh/ssh_config instead of ~/.ssh/config? As far as I know, etc-files are default/system-wide settings, which are copied into user-settings if not existing. I'm afraid changing the original etc-file could cause issues on updates, for instance. Taking a backup of user-settings while migrating from one machine to the next will also be easier.
    – mazunki
    Jul 10, 2020 at 6:48
  • Sure, it's sometimes very convenient to have config settings for all users in your organization. Perhaps you want to make all of your jump hosts easily available to all of your users. /etc/ssh/ssh_config is an easy way to handle it. There's a new feature within ssh that now allows you to include another file in your config file, so ssh_config is less-needed now, but it's still got its uses. Jul 13, 2020 at 18:04
  • Is there an alternative which uses XDG instead of "random" locations? Is it 100% safe to edit /etc/ssh/ssh_config considering updates?
    – mazunki
    Jul 14, 2020 at 15:59
11

You would also need -e if you use a non-default private key location, i.e., specify the private key via -e 'ssh -i /path/to/private/key/file.pem'. For that matter, non-default listen ports for sshd, also. Basically, use -e if just using ssh user@host doesn't work.

3
  • Is -i an option for ssh or rsync in your example? And if it's for ssh, does it work without the single quotes around the command?
    – Izkata
    Apr 12, 2012 at 20:44
  • Oh, right, I need the quotes. Editing my Answer now.
    – cjc
    Apr 12, 2012 at 21:13
  • @Izkata -i sets the identity file for an ssh session. It has nothing to do with rsync, per se. You can also change the command used in git, for instance, by using $GIT_SSH_COMMAND, but usually a better approach is to set up your ssh configuration as explained in the answer above.
    – mazunki
    Jul 10, 2020 at 6:53
10

You don't need -e ssh to use ssh. In fact, if you specify the target as user@host:/path/to/files, you're using ssh by default. It's left in a) for compatibility reasons and b) fringe cases where you might have a combination of rsyncd and ssh hosts.

1
  • 2
    It's required on RHEL 3, for example, as RSYNC_RSH defaults to 'rsh'.
    – Kyle Smith
    Apr 12, 2012 at 18:20
6

It depends on what was specified for the --with-rsh configure option at compile time. The default is now ssh if this option wasn't specified. It had been rsh at some time in the past, however even if it is rsh, It might not be necessary as ssh might be the default rsh implementation on many boxes. On all my machines, for example readlink -f $(which rsh) shows that rsh is really just a symlink pointing to /usr/sbin/ssh

0
READ IT -> i looked this konweledge and after many expirence i get aware

WHOAH:

one important thinks is : rsync prepare file lists "LOCAL" on destiny and source using ssh connection like he is there on machine,

NFS asking every single files between "NETWORK" destiny and source and this make slow very slow if server are far.

even few ms make sens using rsync between two servers with rsa key gen than nfs files,

NFS are also cut transfer by data center for this ports, than 22 port ssh are more faster

https://www.woktron.com/secure/knowledgebase/292/Copy-and-synchronize-backup-data-with-RSYNC-and-public-key-authentication.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .