How to Reboot a Server Over SSH
There are two big things that matter for programmers: knowing what needs to be done, and doing it. So when a server that you SSH into tells you that it wants to be restarted, it’s nice to just do that quick SSH reboot. So long as you trust that nothing will break (a small but import thing) the process of power cycling a server you only have access to over SSH isn’t too many steps.
If you like, here’s a video explaining how you power cycle a remote server that you’ve connected to via SSH:
Step by Step Guide to Restarting a Remote Server using SSH Reboot
And here’s the written form:
- Log in to the server via SSH. You should be able to do this if you’re authorized to change the machine ;p
sudo reboot. This will kick you out of the machine, because it’ll be powering down. You’ll need to wait for the power-cycle, then you’ll be able to reconnect.
- That’s basically it.
The video says a bit more. The big thing to know if that if you’re logged in as the “root” — most powerful — user on the system, the
sudo is unnecessary. But if you’re instead just a normal user — which is generally recommended as a general security measure — you’ll need it.
sudo is a simple command that basically means “for the stuff I type after this, use an elevate permissions level.” Or, in other words “as a ‘super-user'”.
Because non-root users don’t typically have the ability to
reboot over SSH, you’ll need that to do so. But otherwise that’s all you need.
Another thing to note is that you’ll be disconnected if the command executes successfully. This makes sense. A system that’s powering off to then come back up will inherently drop all of it’s external connection, including the one to you via SSH.