Reboot over ssh
Solution 1
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.
Solution 2
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
LecauseAndThePi
Updated on September 18, 2022Comments
-
LecauseAndThePi almost 2 years
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 notbash:
.The router runs on a linux os. uname gives:
Linux Teltonika-RUT950.com 3.18.44 #1
Any idea what could be causing this?
-
LecauseAndThePi almost 6 yearsThanks for the suggestion. I've tried that already. Same result unfortunately.
-
Kusalananda almost 6 years@LecauseAndThePi While logged into the host interactively, use
command -v reboot
to get the path for thereboot
command, then use that in yourssh
call. -
LecauseAndThePi almost 6 yearsi got the full path using
which
. Tried again withcommand -v
to make sure and it's the same 'sbin/reboot/' -
Kusalananda almost 6 years@LecauseAndThePi It is unlikely that the path is
sbin/reboot
and more likely that it's/sbin/reboot
with a/
at the start. -
LecauseAndThePi almost 6 yearsYeah that's correct. Just bad typing on my part
-
LecauseAndThePi almost 6 yearsThanks for the tip. Still doesn't work. To be noted, the error says 'ash: reboot: command not found' . it is not 'bash'
-
LecauseAndThePi almost 6 yearsTHANK 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"