rsync over ssh triggers a "Cannot execute command-line and remote command" error

433 Views Asked by At

I want to copy files using rsync over ssh, but a "Cannot execute command-line and remote command." is raised, meanwhile it works fine with scp.

Command : rsync -ravh folder XXX:folder

My ssh config is configured as follows :

Host XXX
  Hostname YY
  User user
  RequestTTY yes
  RemoteCommand bash --init-file ~/.bashrc

I noticed that by removing the RemoteCommand option, rsync does the job.

How could I manage to make rsync work while using my current ssh host config ?

Thanks in advance.

1

There are 1 best solutions below

0
kaluzki On
  1. Option: define a separate Host (e.g. XXX.ssh) in ~/.ssh/config and use it in your rsync command
Host XXX XXX.ssh
  Hostname YY
  User user

Host XXX
  RequestTTY yes
  RemoteCommand bash --init-file ~/.bashrc
$ rsync -ravh folder XXX.ssh:folder
  1. Option: Override RemoteCommand directive with -e|--rsh rsync option
$ rsync -ravh folder -e "ssh -o RemoteCommand=none" XXX:folder