Skarafaz / mercury

Simple Android app that sends pre-configured commands to remote servers via SSH.
GNU General Public License v2.0
115 stars 20 forks source link

Can Mercury work with root but no sudo? #40

Closed axelsimon closed 10 months ago

axelsimon commented 1 year ago

I think the answer here is no, as the documentation states that Mercury relies on sudo, but i just want to check: what if you connect directly as root?

I know this is not a common (or really recommended) scenario, but some just-enough distributions of Kodi such as LibreELECE or CoreELEC are set up to run basically as an appliance, where the root filesystem is an unpacked squashfs in read only, it offers no option to mess with the packages (so no option to install sudo), and runs everything as root. Which means you ssh into them as root.

Also nohup is available in the default path.

For reference:

# mount
(…)
/dev/loop0 on / type squashfs (ro,relatime)
(…)

@Skarafaz what do you think?

Skarafaz commented 1 year ago

The answer is yes :)

Just set up root as user and remove "sudo" : true from command configuration.

{ "name" : "example", "host" : "192.168.1.100", "user" : "root", "password" : "password if you do not use public key", "commands" : [ { "name" : "Do someting", "cmd" : "do-someting" } ] }

axelsimon commented 1 year ago

Hi and thanks @Skarafaz, sorry for the slow reply!

It's very strange, i can issue commands and MercurySSH appears to log in ok (asking for a password, also when copying the key over, which i can see is properly copied into the target system's ~/.ssh/authorized_keys ), but nothing works beyond that.

Even a simple touch /tmp/test does nothing.

Here is my config:

{
  "name" : "CoreElec",
  "host" : "192.168.1.101",
  "port" : 22,
  "user" : "root",
  "nohupPath" : "/opt/bin/nohup",
  "commands" : [ {
    "name" : "VPN location notification",
    "sudo" : false,
    "cmd" : "vpn-location-kodi-notif",
    "confirm" : false
  }, {
    "name" : "test /tmp file",
    "sudo" : false,
    "cmd" : "touch /tmp/test",
    "confirm" : false
  },{
    "name" : "restart kodi",
    "cmd" : "systemctl restart kodi",
    "confirm" : true
  }, {
    "name" : "reboot",
    "cmd" : "reboot",
    "confirm" : true
  }]
}

vpn-location-kodi-notif is an alias local to the target machine, so i thought that might be why it doesn't work (non-interactive term not loading .profile) but none of the other commands work.