2

I'm trying to reboot a Teltonika RTU950 using ssh.

I can log in as root via ssh and then reboot the router fine. However if i try to send the reboot command over ssh it does not work.

ssh root@routerip 'reboot'

This returns the error:

ash: reboot: not found

I've tried using shutdown -r instead. Also tried using absolute path. Always gives me the same error.

To be noted that the error says: ash: and not bash:.

The router runs on a linux os. uname gives:

Linux Teltonika-RUT950.com 3.18.44 #1

Any idea what could be causing this?

3 Answers 3

4

Try entering the full path to the reboot or shutdown command. For example, if the full path to reboot is /sbin/reboot, run

ssh root@routerip /sbin/reboot

5
  • Thanks for the suggestion. I've tried that already. Same result unfortunately. Sep 7, 2018 at 14:29
  • @LecauseAndThePi While logged into the host interactively, use command -v reboot to get the path for the reboot command, then use that in your ssh call.
    – Kusalananda
    Sep 7, 2018 at 14:35
  • i got the full path using which . Tried again with command -v to make sure and it's the same 'sbin/reboot/' Sep 7, 2018 at 14:39
  • @LecauseAndThePi It is unlikely that the path is sbin/reboot and more likely that it's /sbin/reboot with a / at the start.
    – Kusalananda
    Sep 7, 2018 at 14:50
  • Yeah that's correct. Just bad typing on my part Sep 7, 2018 at 14:52
2


What is your shell when you log in as root?
If it is indeed bash, then you can probably try:
ssh root@routerip /bin/bash -c "/sbin/reboot"

Note that from a security perspective, enabling root login over SSH is a bad idea. You should check the vendor documentation to see if you can fix that.

1
  • THANK YOU. You inherently helped me to get this to work. The shell is actually ash, not bash, even when i ssh interactively. So the command i should use, and works is: ssh root@routerip "/bin/ash -c /sbin/reboot" Sep 10, 2018 at 10:35
0

ssh -t root@device reboot

man ssh for the -t flag

The cause is without the -t flag you get a non-login shell and a different PATH. Besides that, even though giving the full path, the reboot command probably detects it's run non-interactively.

1
  • Thanks for the tip. Still doesn't work. To be noted, the error says 'ash: reboot: command not found' . it is not 'bash' Sep 10, 2018 at 9:06

You must log in to answer this question.

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