How to Enable & Disable SSH login on Linux Cloud Servers

2020-05-21 By Ryan 1613 Views linux ssh networking security
1 reviews

SSH (Secure shell) is a cryptographic network protocol used to connect to a remote server securely and it transfer 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 enabled, the server can access via PUTTY as shown in 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 disabled, then will get the below warning message while try 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 enabled, the server can access via PUTTY as shown in 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 disabled, then will get the below warning message while try to SSH to the server.

    linuxssh9


Related Tutorials

What do you think about this article?

Rate this article