Tuesday, June 4, 2019

Ubuntu Linux: Start / Stop / Restart / Reload OpenSSH Server

Start / Stop / Restart / Reload OpenSSH Server on Ubuntu

Latest version of Ubuntu such as Ubuntu Linux 16.04 LTS or 18.04 LTS and others use the systemctl command to control ssh server on Ubuntu. Older version use the service commandTo find out your Ubuntu Linux version, type:
lsb_release -a
cat /etc/*release*

Sample outputs:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 17.10
Release: 17.10
Codename: artful

Ubuntu Linux: Start OpenSSH Server

Type the following command:
$ sudo /etc/init.d/ssh start
OR
$ sudo service ssh start
OR for systemd based Ubuntu Linux 16.04 LTS or above server:
$ sudo systemctl start ssh

Ubuntu Linux: Stop OpenSSH server

Type the following command:
$ sudo /etc/init.d/ssh stop
OR
$ sudo service ssh stop
OR for systemd based Ubuntu Linux 16.04 LTS or above server:
$ sudo systemctl stop ssh

Ubuntu Linux: Restart OpenSSH server

Type the following command:
$ sudo /etc/init.d/ssh restart
OR
$ sudo service ssh restart
OR for systemd based Ubuntu Linux 16.04 LTS or above server:
$ sudo systemctl restart ssh
systemctl start stop restart openssh server on Ubuntu
systemctl command in action on Ubuntu Linux desktop

Ubuntu Linux: See status of OpenSSH server

Type the following command:
$ sudo /etc/init.d/ssh status
OR
$ sudo service ssh status
OR for systemd based Ubuntu Linux 16.04 LTS or above server:
$ sudo systemctl status ssh

Controlling sshd using upstart based commands (this syntax is no longer works with the latest version of Ubuntu)

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
source : 
https://www.cyberciti.biz/faq/howto-start-stop-ssh-server/

No comments:

Post a Comment