Linux server commands

71 views
Skip to first unread message

Steve

unread,
Sep 9, 2021, 9:06:40 PM9/9/21
to Tasker
     I am trying to send commands to my linux server via auto-tools.  I already can send basic commands (ls for a specific filename, etc).  The problem comes when I need to enter a password for a command, such as sudo reboot or sudo shutdown (for remote emergencies).

     I'm sure the sudo command is being recognized, but I'm not positive.  But how do I send a password when the program asks for it?  I tried the pipe symbol, but I think I'm still missing something.

ktmom

unread,
Sep 10, 2021, 8:51:08 AM9/10/21
to Tasker
sudo -S <<< <password> [command]

Steve

unread,
Sep 10, 2021, 8:41:08 PM9/10/21
to Tasker
nope...ignored the commands.

autotools configuration:
Port: set
username and password: set
something like ls /media/storage will give me the result I need...
but sudo shutdown won't.

If I go onto the server itself, I get the password prompt.  But sending from my phone, I don't get anything back.  

ktmom

unread,
Sep 11, 2021, 9:10:38 AM9/11/21
to Tasker
You're not waiting for a password prompt, you're are sending one line that will enter the password and execute the command. The "blank" response from the server is likely a second password prompt waiting for input.  It suggests the command sent was malformed.

    A1: AutoTools SSH [
         Configuration: Server: 192.168.17.63
         Port: 22
         Username: xxxxxxxx
         Password: *******
         Command: sudo -S <<< *******  shutdown -P now
         Command Variable: atsshresult
         Timeout (Seconds): 60
         Structure Output (JSON, etc): On ]
    
If you have special symbols in your password, you might quote around the password.

   A1: AutoTools SSH [
         Configuration: Server: 192.168.17.63
         Port: 22
         Username: xxxxxxxx
         Password: *******
         Command: sudo -S <<< "*******"  shutdown -P now
         Command Variable: atsshresult
         Timeout (Seconds): 60
         Structure Output (JSON, etc): On ]
   
If you still can't make it work, consider adding the shutdown command to your user in the sudoers file.  Of course, this method probably shouldn't be used except on a server isolated from the Internet.

This is a Linux challenge, not a Tasker one.  It would be a similar challenge running a command from a script.

Steve

unread,
Sep 12, 2021, 4:41:21 PM9/12/21
to Tasker
thank you all.  I found a solution that works for me without compromising security.
Reply all
Reply to author
Forward
0 new messages