Answer for KodeKloud Question - Disable Root Login

 After doing some security audits of servers, xFusionCorp Industries security team has implemented some new security policies. One of them is to disable direct root login through SSH.

Disable direct SSH root login on all app servers in Stratos Datacenter.


Answer:

#we need to login each app server and set PermitRootLogin to (no) in the sshd config file 

#login to server

    ssh <user>@<server>

# switch to root user

    sudo su 

# before chnage,  first  verify using below command or you can simply cat the sshd_config file ans find the entry PermitRootLogin

    cat /etc/ssh/sshd_config | grep PermitRootLogin

# edit the file and do the change and save it

 vi etc/ssh/sshd_config

press i to switch insert mode and edit line as below and make sure that you remove # in front of the line.

    PermitRootLogin no

#save the file 

   press Esc and  wq!

# you must restart the sshd service otherwise task change will not work.

    systemctl restart sshd

* do the above steps for all the app servers 


Note: Commands are correct but based on your question the server and user name, other details might differ so please do check.

No comments:

Post a Comment

Featured Post

Answer for Kodekloud DEVOPS Questions - Init container in Kubernetes

Question: 1. Create a Deployment named as ic-deploy-devops. 2. Configure spec as replicas should be 1 , labels app should be ic-devops , ...