Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 253
infrahinium Avatar asked Aug 12 '26 08:08

infrahinium


1 Answers

  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
like image 74
kaluzki Avatar answered Aug 14 '26 09:08

kaluzki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!