Перезапуск службы ssh linux

How to Restart the SSH Service?

SSH is an open-source client-server architecture that enables encrypted system connection. It is also known as the practical implementation of SSH protocol. This connection can be utilized to transfer files and access the terminal.

It is mainly used for the encrypted connection that securely transfers information between the server and the client. Sometimes the SSH service slows down or may generate an operational error. So restarting it in such scenarios and performing the task smoothly is recommended.

This guide lists down the possible ways to restart SSH Service on Linux with the following highlights:

Method 1: Using the “systemctl” Command

The “systemctl” command-line tool manages the “systemd” initialization system and service manager. It allows the user to interact with the services using options such as “start”, “enable”, “stop”, “disable”, and view.

Restart SSH Service

Execute the “systemctl” command followed by the “restart” options and the superuser privileges i.e “sudo” to restart the “SSH” service:

$ sudo systemctl restart ssh

The error-free output confirms that “SSH” service is restarted.

Check SSH Service Status

If the user wants to check the current status of the “SSH” service, then use the “status” with the “systemctl” command:

$ sudo systemctl status ssh

The SSH service is now in an “active (running)” state.

Method 2: Using the “service” Command

The other tool is the “service” command utility utilized to execute a SystemV init script in the in /etc/init.d directory. It can also start, stop, restart, reload, and enable the services like the systemctl command.

Restart SSH Service

Type the “restart” flag alongside the “sudo” and “service” commands for restarting the “ssh” service in the following way:

It provides the same output as the “systemctl” command.

Method 3: Using “/etc/init.d” Directory

The “etc/init.d” is the directory that contains the start and stop scripts to manage the start, stop, restart, and reload process of the service at boot time. It requires the superuser privileges to access and control the script using the terminal manually.

Restart SSH Service

Specify the name of the “SSH” service with the “restart” control command in the terminal to restart it:

Conclusion

Linux offers the “systemctl” and “service” command line tools to restart the “SSH” service instantly. It can also be restarted by accessing the “/etc/init.d” directory using the “restart” command. All commands use the “sudo” i.e, root user access if the normal user is logged in. This guide has demonstrated all possible ways to restart the SSH Service.

Источник

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.

Читайте также:  Linux информация жестких дисков

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.

Читайте также:  Установить google chrome linux mint

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.

restart ssh

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.

Читайте также:  Удаление ядра astra linux

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:

  1. Open a terminal window.
  2. 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:

  1. Open a terminal window.
  2. 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:

  1. Open the Start menu and search for services.msc .
  2. Click on the Services app to open it.
  3. Scroll down to find the OpenSSH SSH Server service.
  4. 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.

Read also

Источник

Оцените статью
Adblock
detector