How do I reboot host via SSH?

After some configuration changes, I get “502: Bad Gateway” displayed for the Hass.io panel. I am able to SSH in, but CLI is not working and I want to try restarting the Raspberry Pi next. I don’t have physical access to pull the plug at the moment.

Like I said, I can SSH in, but I get this trying to use the CLI:

core-ssh:~# hassio
/usr/bin/hassio: line 6: cannot create temp file for here-document: Read-only file system

I tried to use other commands, but here are the results:

core-ssh:~# docker
-ash: docker: not found

core-ssh:~# sudo shutdown -r now
-ash: sudo: not found

Thanks for any help.

You don’t need sudo as you’re already root (signified by the # symbol), shutdown -r now should work.

1 Like

Thanks.

Doesn’t work though, it seems that I get the “-ash: command: not found” for most commands:

core-ssh:# shutdown -r now
-ash: shutdown: not found

1 Like

because you are in the SSH Add-on and not the host SSH session.

Hi,
Just tested on mine, the following worked:

reboot now

:slight_smile:

I am SSH-ing directly from my own machine. Hassio 0.62 and SSH plugin version 3.2.

3 Likes

Still, this command inside the SSH Add-on does not work:

core-ssh:~# reboot now
-ash: reboot: not found

because you NEED to be in the host SSH session…you can’t control the HOST from the docker container running the SSH add-on

Ok, makes sense. I’ll try to get access to the host next. Thanks.

This thread helped clear things up for me:

and

What I want to do is not possible until I have physical access to set up host SSH.

Thanks for the replies.

hassio homeassistant restart

He wants to reboot the host, so from SSH he wants

hassio host reboot

3 Likes

so you CAN control the host from the SSH add-on using that command? That’s cool

You can !

From SSH if you type just

hassio

it will list all your options :slight_smile:

Yes, but in my case, the Cli is dead… without SSH access directly to the host I cannot reboot the device, docker or Hass.io without physically pulling the plug.

core-ssh:~# hassio host reboot
API error:
core-ssh:~# hassio
/usr/bin/hassio: line 6: cannot create temp file for here-document: Read-only file system

I have access to Home Assistant in the browser, but anything related specifically to Hass.io, like the panel etc. is dead.

You can’t SSH in to the rpi from the command line on your PC / laptop ?

Just re-read your OP. Your not on the same LAN as the rpi ?

I’m not on the same LAN - I use port forwarding - I do not have VPN setup.

So, is the SSH Add-on on port 22 by default and the host SSH is on port 22222? I’m wondering if I could just forward that port and that would work. Not sure about the authorized keys however.

Nevermind, the RPI refuses a connection on 22222.

Have you put your SSH keys on the SD card?

Yes 22. Connect on 22 and type reboot

/sbin/reboot now worked for me.

6 Likes

Thanks took me forever to find this answer!! Whys it not documented? Some basic instructions for beginners would really help.

2 Likes