How To Start / Stop / Restart / Enable / Reload The OpenSSH Service In Linux?

systemd is a new system and service manager for Linux system, which was implemented/adapted into all the major Linux distributions over the traditional SysV init systems due to lots of issue/improvement has to be on SysVinit systems.

All the service files are available on /etc/init.d/ directory for SysVinit system.

For systemd system, the service files are available on /usr/lib/systemd/system/ directory.

If you would like to perform any kind of actions like start, stop, restart, enable, reload & status against the specific service then use the following commands.

Make sure that you should have admin privileges to run these commands except status command. It should be root or sudo permission needed to run the below commands.

What Is ssh?

openssh stands for OpenBSD Secure Shell. Secure Shell (ssh) is a free open source networking tool which allow us to access remote system over an unsecured network using Secure Shell (SSH) protocol.

It’s a client-server architecture. It handles user authentication, encryption, transferring files between computers and tunneling.

These can be accomplished via traditional tools such as telnet or rcp, these are insecure and use transfer password in cleartext format while performing any action.

1) How To Start The ssh Service In Linux?

Use the below commands to start the ssh server in Linux.

For SysVinit Systems

# service sshd start
or
# /etc/init.d/sshd start

For systemd Systems

# systemctl start sshd
or
# systemctl start sshd.service

2) How To Stop The ssh Service In Linux?

Use the below commands to stop the ssh server in Linux.

For SysVinit Systems

# service sshd stop
or
# /etc/init.d/sshd stop

For systemd Systems

# systemctl stop sshd
or
# systemctl stop sshd.service

3) How To Restart The ssh Service In Linux?

Use the below commands to restart the ssh server in Linux.

For SysVinit Systems

# service sshd restart
or
# /etc/init.d/sshd restart

For systemd Systems

# systemctl restart sshd
or
# systemctl restart sshd.service

4) How To Reload The ssh Service In Linux?

Use the below commands to reload the ssh server in Linux.

For SysVinit Systems

# service sshd reload
or
# /etc/init.d/sshd reload

For systemd Systems

# systemctl reload sshd
or
# systemctl reload sshd.service

5) How To View The ssh Service Status In Linux?

Use the below commands to view the ssh server status in Linux.

For SysVinit Systems

# service sshd status
or
# /etc/init.d/sshd status

For systemd Systems

# systemctl status sshd
or
# systemctl status sshd.service

6) How To Enable The ssh Service On Boot In Linux?

Use the below commands to enable the ssh server on boot in Linux.

For SysVinit Systems

# chkconfig sshd on

For systemd Systems

# systemctl enable sshd
or
# systemctl enable sshd.service

The default configuration file is located at /etc/ssh/sshd_config. There are lots of options are available to secure this if you want.

/etc/ssh/sshd_config

For All service commands View More

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...