[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cannot rum multiple command on remote machine via SSH



Am 04/02/2023 um 15:15 schrieb Greg Wooledge:
On Sat, Feb 04, 2023 at 02:13:54PM +0000, Ottavio Caruso wrote:
$ ssh LAP2 hibernate.sh # it works too

$ ssh LAP2 "sudo tlp setcharge 90 95 BAT1 ; hibernate.sh"

return:

hibernate.sh: command not found

No, this is not good. The "hibernate.sh" must be run as standard user.

Where is "hibernate.sh" located?

How is PATH being set in the case where it works?  And in the other case?

Is LAP2 a Debian system, or something else?

Is your account's shell on LAP2 /bin/bash, or something else?

Are you using key authentication, or password?  If it's key auth, is there
a forced command in the authorized_keys file?

unicorn:~$ cat /etc/debian_version ; echo "$SHELL"
11.6
/bin/bash
unicorn:~$ ssh localhost 'echo "$PATH"'
greg@localhost's password:
/usr/local/bin:/usr/bin:/bin:/usr/games
unicorn:~$ ssh localhost '/bin/true; echo "$PATH"'
greg@localhost's password:
/usr/local/bin:/usr/bin:/bin:/usr/games

I don't see any specific difference in PATH resulting from having
an external command followed by a semicolon, but maybe your setup
is special in some way.  (I don't alter PATH in .bashrc, for example,
whereas perhaps you do.)  We're going to need more details on how to
reproduce your results.

hibernate.sh: command not found

unicorn:~$ ssh localhost 'frobbb.sh'
greg@localhost's password:
bash: line 1: frobbb.sh: command not found

That's a VERY different error message.  This makes me think your shell
isn't bash.  If I change my shell...

unicorn:~$ grep greg /etc/passwd
greg:x:1000:1000:Greg Wooledge,,,:/home/greg:/bin/dash
unicorn:~$ ssh localhost 'frobbb.sh'
greg@localhost's password:
dash: 1: frobbb.sh: not found

I STILL don't get your error message.  So your shell isn't bash or dash,
then...?



If only you ever read OPs properly.

--
Ottavio Caruso

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?



Reply to: