ssh "!command" escape sequence - does it work?

Chris Green cl at isbd.net
Fri Sep 11 12:11:54 UTC 2020


On Fri, Sep 11, 2020 at 08:01:54PM +1000, Karl Auer wrote:
> On Fri, 2020-09-11 at 09:13 +0100, Chris Green wrote:
> > Yes, I do have that set and have checked by setting LocalCommand as
> > well.  Reading parts of the documentation seems to suggest that
> > '!command' actually executes the command set in LocalCommand with new
> > parameters - but I can't make that happen either.
> 
> Yes -f you do ~C then h[enter] or ?[enter] it mentions a command
> "!args".
> 
Yes, that's where I got it from.


> Haven't spent long on it but it is a mystery to me, too.
> 
> Here are my adventures so far, tantalising!
> 
> myhost: ~$ ssh -o LocalCommand="ls" otherhost
> [file listing of my home directory is output]
> otherhost:~$ [press ~C]
> ssh> !/ [enter]
> /bin/bash: /: Is a directory
> [enter]
> otherhost:~$ [press ~C]
> ssh> echo "Boo" [enter]
> Invalid command.
> [enter]
> otherhost:~$ [press ~C]
> ssh> !echo boo
> [enter]
> otherhost:~$ [press ~C]
> ssh> !-la
> /bin/bash: -c: option requires an argument
> [enter]
> otherhost:~$ exit
> 
> So I dunno what's going on. Except that LocalCommand  is executed
> locally, as soon as the connection to otherhost succeeds.
> 
Yes, as it's supposed to be.  As you say though the rest of the
!command escape seems to be, at the very least, not quite what one
expects.  I've searched around quite a bit but I've not found anything
very helpful.


> Also tried CTL-D instead of enter, but that just exited the shell.
> 

-- 
Chris Green




More information about the ubuntu-users mailing list