Ubuntu Linux: Start / Stop / Restart OpenSSH ( SSH ) Server

by on October 8, 2007 · 5 comments· LAST UPDATED May 13, 2013

in , ,

I need to provide a remote access to my Ubuntu Linux based server. How do I start / stop OR restart the ssh server under Ubuntu Linux operating system using command line options?

You need to run a script called /etc/init.d/ssh to stop, start, and restart the OpenSSH server.
Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsUbuntu/sudo
Estimated completion timeN/A
You can also use the service command to control a System V init script. If you are using the latest version of Ubuntu such as 12.04 LTS or 13.04+, you need to use upstart job based commands as listed below.

Ubuntu Linux: Start OpenSSH Server

Type the following command:
$ sudo /etc/init.d/ssh start
OR
$ sudo service ssh start

Ubuntu Linux: Stop OpenSSH server

Type the following command:
$ sudo /etc/init.d/ssh stop
OR
$ sudo service ssh stop

Ubuntu Linux: Restart OpenSSH server

Type the following command:
$ sudo /etc/init.d/ssh restart
OR
$ sudo service ssh restart

Ubuntu Linux: See status of OpenSSH server

Type the following command:
$ sudo /etc/init.d/ssh status
OR
$ sudo service ssh status


Controlling sshd using upstart based commands

Since the script /etc/init.d/ssh has been converted to an Upstart based job, try the following commands to start / stop / restart the OpenSSH server:

Stop/Start/Restart the OpenSSH using the following commands

The syntax is:

 
sudo stop ssh
sudo start ssh
sudo restart ssh
sudo status ssh
 

Sample outputs:

Fig.01: Ubuntu using initctl (upstart) to control sshd process

Fig.01: Ubuntu using initctl (upstart) to control sshd process

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 5 comments… read them below or add one }

1 ORLY July 30, 2008 at 8:31 pm

Really? Starting, stopping, and restarting all require the exact same instructions?

Reply

2 nixCraft July 31, 2008 at 3:42 am

Thanks for the heads up, it was a typo. The FAQ has been updated.

Reply

3 Alex Beamish October 25, 2011 at 2:22 pm

Maybe this should be updated with the new ‘service $foo (start|stop|restart)’ offering?

Reply

4 Maxim Dsouza May 3, 2012 at 1:32 pm

Isnt it suprising that all the restarts have the same syntax. But yes they do.

Reply

5 Omkar Panda July 4, 2013 at 5:52 am

Stop/Start/Restart the OpenSSH using the following commands

The syntax is:

sudo stop ssh
sudo start ssh
sudo restart ssh
sudo status ssh

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: