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?


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!

  • 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 '20 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. – UtahJarhead Jul 13 '20 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 '20 at 15:59

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.

  • 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 '12 at 20:44
  • Oh, right, I need the quotes. Editing my Answer now. – cjc Apr 12 '12 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 '20 at 6:53

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.

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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