- How To Start / Stop / Restart / Enable / Reload The OpenSSH Service In Linux?
- What Is ssh?
- 1) How To Start The ssh Service In Linux?
- 2) How To Stop The ssh Service In Linux?
- 3) How To Restart The ssh Service In Linux?
- 4) How To Reload The ssh Service In Linux?
- 5) How To View The ssh Service Status In Linux?
- 6) How To Enable The ssh Service On Boot In Linux?
- How to Do an SSHd Restart
- Conclusion
- About the author
- Saeed Raza
- How to Restart SSH: A Guide for Beginners
- Restarting SSH on Linux
- Restarting SSH on macOS
- Restarting SSH on Windows
- Conclusion
- Alex Ivanovs
- Read also
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.
# service sshd start or # /etc/init.d/sshd start
# 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.
# service sshd stop or # /etc/init.d/sshd stop
# 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.
# service sshd restart or # /etc/init.d/sshd restart
# 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.
# service sshd reload or # /etc/init.d/sshd reload
# 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.
# service sshd status or # /etc/init.d/sshd status
# 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.
# 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.
How to Do an SSHd Restart
OpenSSH is a suite of techniques for controlling connected machines transmitting information amongst them. You’ll also discover how to adjust a few of the OpenSSH server’s customization options on the Linux machine. Conventional techniques for doing these tasks, like telnet as well as RCP, seem to be unsafe and communicate the passcode in plaintext form. OpenSSH is a server host plus client software that allows for safe, encoded remote control and file transmission, essentially replacing traditional technologies. We will let you know about installing it on our system, stopping and restarting it within Ubuntu 20.04 system.
Let’s get started with implementing sshd restart in the Ubuntu 20.04 Linux system. For this, we need to get started with the terminal shell. It has to be launched through the “Ctrl+Alt+T” shortcut. The terminal will be popped up in a few seconds. There comes the execution of an update instruction in the terminal query area. The update command is used to ensure that our Ubuntu 20.04 system is up to date and refreshed. The “apt” package is here for our help to execute this command appropriately. Now, the system is updated.
Let’s first check the available version for SSH in our Ubuntu 20.04 system to be installed. The version command is utilized in the query area of the shell, i.e., “-V” fag with the shh keyword. The version is displayed in the output area.
We need to add the ssh package to our system using the “apt-get” package command. This ssh package is an openssh-server application required to be configured on our end. You can also install the openssh-client application. But, we are only elaborating the server application installation for openssh here. Therefore the below-shown installation command is used.
The openssh-server application package is started to download. The download process asked for your affirmation to continue processing and installing it on our system. We have to add the alphabet “Y” to continue it. We did the same as we mentioned and tapped Enter. It started installing the openssh-server package on our system until it was done.
The installation will be completed within a few minutes, as shown below. Now, we are ready to go along with the enabling and use of sshd.
Now, you have to update some of the configurations for openssh-server in its configuration file. To open its configuration file, we need to use the sudo privileges and the “sshd” keyword. This command contains the path to the sshd configuration file held in our system’s “/etc/ssh/” folder. The “-f” flag forces the system to open the file without hesitation.
After using the above sshd_config command to open the configuration file, we will encounter the opening of a file within the terminal. It will show us many of the settings already configured in it. First, you have to go to the “Port” option and set it to 2222, as shown in the image below. This configuration setting can be found below the “include” path line.
After the port configuration, you need to update the banner line. You have to add the “/etc/issue.net” path in front of it to ensure that our SSH server must show the path file contents. This line may be found as commented. Update it after removing the # sign.
After updating all the configurations and settings of sshd using its configuration file, we are now ready to enable our openssh server. The systemctl command is quite well-known amongst Linux users when it comes to enabling, disabling, stop and starting any service. So, we have been using the systemctl command here first to enable the ssh server. The “enable” word is the key here, along with the “ssh” keyword. It will enable the ssh server by synchronizing the sysv script. The output for this command has been shown below within the image.
Now it is enabled and ready to be started. So, the systemctl command will be utilized once again to start the ssh service. After the start of ssh service, we have to check whether it is appropriately active and running. The same systemctl has been utilized once again for this. There is only a single word difference in both the commands, i.e., start and status. The output shows the Openssh Service is currently active and running properly.
To check the status of ssh service, you can also use the keyword sshd instead of ssh as below.
Let’s just deactivate its service and prevent it from working correctly. So, the same systemctl command will be utilized with the “stop” keyword along with the sshd server name.
After that, we need to disable this service from our system using the disable keyword in the systemctl sshd command. You can see that the service files are being removed from the system.
After checking the sshd service status utilizing the systemctl command in the terminal, we have found that the service is now inactive and dead. The output is shown below.
We have to utilize the same systemctl command with the “restart” keyword to restart the ssh service. The sudo privileges are essential in the command. After restarting, this service needs to be enabled using the systemctl command and the keyword “enable” in it. The service will be enabled by the synchronization as shown in the output.
Now, we have to validate the status of the sshd service once again. The same systemctl command comes here for our help. The “status” keyword is utilized in the command and the “sshd” service name. The output for this command shows that the sshd service is restarted.
Conclusion
We have completed this guide for the implementation of sshd service restart. We have started it by installing the openssh-server and enabling it on the Ubuntu 20.04 system. After that, we have seen how to stop and disable it. At last, we have shown how to restart this service in Ubuntu 20.04 system.
About the author
Saeed Raza
Hello geeks! I am here to guide you about your tech-related issues. My expertise revolves around Linux, Databases & Programming. Additionally, I am practicing law in Pakistan. Cheers to all of you.
How to Restart SSH: A Guide for Beginners
Secure Shell (SSH) is a network protocol that allows users to securely communicate with remote computers. It is widely used by system administrators and developers to manage servers and execute commands remotely. However, sometimes the SSH service may stop working due to various reasons, such as configuration changes, software updates, or network issues. In such […]
| Reader Disclosure Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission.
Secure Shell (SSH) is a network protocol that allows users to securely communicate with remote computers. It is widely used by system administrators and developers to manage servers and execute commands remotely. However, sometimes the SSH service may stop working due to various reasons, such as configuration changes, software updates, or network issues. In such cases, restarting the SSH service can help to resolve the problem and restore the connection. In this article, we will explain how to restart SSH on different operating systems and provide some useful tips and tricks.
Restarting SSH on Linux
Linux is a popular operating system for servers and desktops, and it comes with built-in support for SSH. To restart SSH on Linux, you can use the systemctl command, which is a universal tool for managing services. Here’s how to do it:
- Open a terminal window.
- Type the following command to check the status of the SSH service:
This will show you whether the service is running, stopped, or in a failed state. If the service is running, you can skip to step 4.
sudo systemctl start sshd
This will start the SSH service and enable remote access to your system.
This should show you that the service is active and running without errors.
This will disable remote access to your system.
Restarting SSH on macOS
macOS is a popular operating system for Apple computers, and it also comes with built-in support for SSH. To restart SSH on macOS, you can use the launchctl command, which is a tool for managing launchd jobs and agents. Here’s how to do it:
- Open a terminal window.
- Type the following command to check the status of the SSH service:
sudo launchctl list | grep ssh
This will show you whether the service is running or not. If the service is running, you can skip to step 4.
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
This will start the SSH service and enable remote access to your system.
sudo launchctl list | grep ssh
This should show you that the service is active and running without errors.
sudo launchctl unload -w /System/Library/LaunchDaemons/ssh.plist
This will disable remote access to your system.
Restarting SSH on Windows
Windows is a popular operating system for desktops and servers, and it also supports SSH through third-party tools, such as OpenSSH and PuTTY. To restart SSH on Windows, you can use the services.msc tool, which is a graphical interface for managing services. Here’s how to do it:
- Open the Start menu and search for services.msc .
- Click on the Services app to open it.
- Scroll down to find the OpenSSH SSH Server service.
- Right-click on the service and select Restart .
This will restart the SSH service and enable remote access to your system.
Conclusion
Restarting SSH is a simple but powerful technique for troubleshooting connectivity issues and managing remote servers. By following the steps outlined in this article, you should be able to restart SSH on different operating systems and ensure that it is running smoothly. However, if you encounter any problems or errors, you may need to consult the documentation or seek help from the community. Remember to always use strong passwords and encryption when using SSH, and keep your system up-to-date with the latest security patches.
Alex Ivanovs
Alex is a full-stack developer with more than 15 years of experience. After many years of threading the self-taught path, he discovered a natural passion for writing. His past work includes helping build the Huffington Post Code column and working with publishers such as Entrepreneur, TheNextWeb, and many prominent tech startups.