July 26, 2017

How to Disable SSH root Login

Administration Logo

When you run a server, SSH (Secure Shell) is a service with which you have to do on each case. It is important for the security of your server that the login with the root user is locked from outside. We show you how to do it. It’s very simple.

Root access is required to edit the following files and to execute commands. Log in as root (su) or simply prepend sudo to all commands that require root privileges.

Before you do this, be sure you have created an additional user besides root. Otherwise you will not be able to access your machine!

FreeBSD security model

On a FreeBSD machine add your user to the group wheel. Otherwise you will not be able to execute the su command and your root access will be blocked. Change the /etc/group file as follows

wheel:*:0:root,stan

Edit SSH configuration

Open the file /etc/ssh/sshd_config with your favorite text editor.

vi /etc/ssh/sshd_config

Find the directive PermitRootLogin, uncomment it and change the value to no.

PermitRootLogin no

Restart SSH

# CentOS
service sshd reload
# FreeBSD
/etc/rc.d/sshd restart

Speak Your Mind