Skip to content

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:

  1. Log in to the server via SSH. You should be able to do this if you’re authorized to change the machine ;p
  2. Type 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.
  3. 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.

For more advice about using the Unix command line and more, check out this recent article.

Yay! 🎉 You made it to the end of the article!
David Hayes
Share:

4 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Matthew H. McKenzie
November 7, 2018 5:49 pm

This is self evident.

How about an article on setting up dedicated users that reboot and shutdown respectively upon login?

That is what most people mean when they speak of an SSH shutdown, and by an rc file on the machine, nothing plinky nor scripty on the client side.

Doing it by hand is messy, and it will be only a matter of time before before you bring down the wrong machine.

foo bar bar
January 26, 2018 10:33 am

Only two words in the command and you spent 1:37 to get one of them wrong.

Fred Meyer
January 26, 2018 11:54 am
Reply to  foo bar bar

Okay then YOU do a good one then

Tom Dana
February 3, 2017 8:59 am

Thank you for all the great Unix command line articles!

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!