0

Using MUSSH on remote machine to execute a bash script

$ mussh -a -i ~/.ssh/id_rsa -d -H mas-hostfile -c 'bash script.sh' -m2
sudo: unable to resolve host hostname
[email protected]: sudo: no tty present and no askpass program specified

If I directly ssh one of the machine and execute the script, all things goes correctly.

1
  • If I modify the command line by: mussh -a -i ~/.ssh/id_rsa -d -H mas-hostfile -c 'bash-s < ~/script.sh' -m2 . The trouble stay the same
    – aurelien
    Mar 22, 2016 at 4:55

2 Answers 2

1

You can tell mussh to ask ssh to allocate a terminal using the -o option with RequestTTY value, e.g.,

mussh -o RequestTTY=yes -a -i ~/.ssh/id_rsa -d -H mas-hostfile -c 'bash script.sh' -m2

If you used ssh directly, you could use its -t option, but mussh uses -t for a different purpose (and does not pass that to ssh):

-t
Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.

RequestTTY
Specifies whether to request a pseudo-tty for the session. The argument may be one of: no (never request a TTY), yes (always request a TTY when standard input is a TTY), force (always request a TTY) or auto (request a TTY when opening a login session). This option mirrors the -t and -T flags for ssh(1).

Further reading:

9
  • With that command line I get: command-line line 0: missing argument.
    – aurelien
    Mar 22, 2016 at 9:06
  • I have modify your line by mussh -o RequestTT=yes -a -i ~/.ssh/id_rsa -d -H hostfile -c 'bash script.sh' -m2 but it continue to says: sudo: no tty present and no askpass program specified
    – aurelien
    Mar 22, 2016 at 9:14
  • you could use the -v option to see what is actually passed to ssh, to get more information. Mar 22, 2016 at 9:20
  • Authenticated aurelien@...: debug1: setting up multiplex master socket aurelien@...: debug1: channel 0: new [/tmp/ssh-aurelien@...] aurelien@...: debug1: channel 1: new [client-session] aurelien@...: debug1: Entering interactive session. aurelien@...: debug1: pledge: id aurelien@...: debug1: client_input_global_request: rtype [email protected] want_reply 0 aurelien@...: debug1: Sending environment. aurelien@...: debug1: Sending env LANG = en_US.UTF-8 aurelien@...: debug1: Sending command: bash aurelien@...: sudo: no tty present and no askpass program specified
    – aurelien
    Mar 22, 2016 at 9:59
  • End of the debug output a@: sudo: no tty present and no askpass program specified a@: debug1: client_input_channel_req: channel 1 rtype exit-status reply 0 a@: debug1: channel 1: free: client-session, nchannels 2 a@: debug1: channel 0: free: /tmp/ssh-a@, nchannels 1 a@: debug1: fd 0 clearing O_NONBLOCK a@: debug1: fd 1 clearing O_NONBLOCK a@: Transferred: sent 2700, received 3104 bytes, in 0.7 seconds a@: Bytes per second: sent 3614.0, received 4154.7 a@: debug1: Exit status 1 DEBUG: Removing keys from agent DEBUG: Stopping Agent
    – aurelien
    Mar 22, 2016 at 10:21
0

Ok so I have solve the trouble! (after hours and fight)

Here is the full working code [ https://github.com/aurelien-git/MAS ]

The solution was not to use RequestTTY

But to had the authorized_keys in the /root/.ssh/authorized_keys

Now the command can be load normaly

mussh -a -i /home/aurelien/.ssh/id_rsa -d -H mas-hostfile -C 'update.sh' -m2

and much more ;-)

3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .