Rebuilt Emacs from the latest Git commit, doesn't happen anymore. Maybe it got fixed as a side-effect of this commit (06.10):

87301f2623 Better support for remote file names in dired

Paul

On Tue, 25 Oct 2022 at 04:15, Filipp Gunbin <fgunbin@fastmail.fm> wrote:
On 24/10/2022 17:01 +0200, Paul Pogonyshev wrote:

> GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.33,
> cairo version 1.16.0) of 2022-09-14
>
> To reproduce:
>
> 1. $ emacs -Q /ssh:ANY-REMOTE-DIRECTORY-WITH-FILES
> 2. Move point to a file, let's say it is called XYZ
> 3. Run ! "ls" RET -> 'ls' gives an error, because it gets a Emacs-style
> remote path, which it of course doesn't understand.
>
> So, Emacs command doesn't fail per se, but it invokes shell commands in
> such a way they cannot succeed.
>
> For comparison, M-! "ls XYZ" RET works fine.
>
> Paul

I cannot reproduce this with latest master, ssh-ing to Debian Bullseye.

Perhaps you should give more details about your target machine.

Thanks.