How to Enable & Disable SSH login on Linux Cloud Servers

2020-05-21 By Ryan 11754 Views linux ssh networking security
2 reviews

SSH (Secure shell) is a cryptographic network protocol used to connect to a remote server securely and it transfers the data in encrypted form between the host and the client. The default TCP/IP port for the SSH is 22.


This guide will describe the steps to enable and disable SSH login in the Linux server.


CentOS

By default, the OpenSSH Server Software Package is included on CentOS. If it is not present, please complete the following procedure.


  1. Run the below command to install OpenSSH Server Software Package.

    # yum install openssh-server openssh-clients
    

    linuxssh1

  2. Run the below command to start and check the status of the SSH daemon on the OpenSSH server.

    # systemctl start sshd  
    # systemctl status sshd
    

    linuxssh2


Enable SSH login (CentOS)


  1. Run the below command and then reboot the server to Enable SSH.

    # systemctl enable sshd
    

    linuxssh3

  2. Once it is enabled, the server can access it via PUTTY as shown below.

    linuxssh4

    NOTE: Replace the sample IP (123.123.123.123) with the original server IP and replace the port if set custom.

    linuxssh5

  3. Enter the password to access the server.


Disable SSH login (CentOS)


  1. Run the below command and then reboot the server to Disable SSH.

    # systemctl disable sshd
    

    linuxssh6

  2. Once the SSH is disabled, then will get the below warning message while trying to SSH to the server.

    linuxssh7


Ubuntu / Debian

By default, the OpenSSH Server Software Package is included on Ubuntu & Debian. If it is not present, please complete the following procedure.


  1. Run the below command to install OpenSSH Server Software Package.

    # apt-get install openssh-server -y
    

    linuxssh8

  2. Run the below command to start and check the status of the SSH daemon on the OpenSSH server.

    # systemctl start sshd
    # systemctl status sshd
    

    linuxssh9


Enable SSH login (Ubuntu / Debian)


  1. Run the below command and then reboot the server to Enable SSH.

    # systemctl enable ssh
    

    linuxssh10

  2. Once it is enabled, the server can access it via PUTTY as shown below.

    linuxssh11

    NOTE: Replace the sample IP with the original server IP (123.123.123.123) and replace the port if set custom.

    linuxssh12

  3. Enter the password to access the server.


Disable SSH login (Ubuntu / Debian)


  1. Run the below command and then reboot the server to Disable SSH.

    # systemctl disable ssh
    

    linuxssh9

  2. Once the SSH is disabled, then will get the below warning message while trying to SSH to the server.

    linuxssh9


Related Tutorials

What do you think about this article?

Rate this article
Need assistance?

Try this guide to receive free bundled services at signup on a new free account.

Sign Up

Your Feedback Is Important

We hope you’ll give the new products and updates a try. If you have an idea for improving our products or want to vote on other user ideas so they get prioritized, please submit your feedback on our Community platform. And if you have any questions, please feel free to ask in the Community or contact our Technical Support team.