How to enable the ssh service in Linux?

To enable SSH service on Linux, you need to follow these steps:

  1. Open a terminal window or connect to a remote server.
  2. Log in as the root user or a user with sudo privileges.
  3. Install the OpenSSH server software package. On most Debian-based distributions (such as Ubuntu), you can use the following command to install it:
  4. Install the OpenSSH server using the “apt-get” command with elevated privileges.
  5. On Red Hat-based distributions (such as CentOS), you can install using the following command:
  6. Elevate your privileges and use yum to install openssh-server.
  7. After installation is complete, the SSH service will start automatically. You can check the status of the SSH service using the following command.
  8. Check the status of the ssh service using systemctl command.
  9. If the service is running, it will display an Active status.
  10. If the SSH service is not running, you can manually start it using the following command:
  11. Initiate the ssh service using systemctl.
  12. To automatically start the SSH service when the system boots, use the following command:
  13. Enable the ssh service using systemctl command.
  14. After completion, the SSH service is enabled and running. You can use an SSH client to connect to the server.

For security reasons, it is recommended to use SSH key authentication instead of password authentication in a production environment. Once the SSH service is enabled, you can configure and use SSH key authentication.

bannerAds