DbAppWeb.com

Menu
  • Home
  • Linux
  • HP-UX
  • macOS
  • Windows
  • Web Servers
  • App Servers
  • Storage

How to Disable Root SSH Login in RHEL

July 20, 2017 DbAppWeb Admin

Root SSH login on the servers should be disabled to protect the servers from unauthorized access. Root login should be enabled through the console only. If you need root user access to run a script or execute a command then you need to login first through your user and then switch to the root user. Here it is shown that how you can secure your Red Hat Enterprise Linux (RHEL) systems by restricting the root user SSH login to console only.

Disable root SSH Login in Linux (RHEL):

  • Login as a root user on the server
  • Edit the file /etc/ssh/sshd_config as shown below:
[root@TestServer ~]# vi /etc/ssh/sshd_config

.
.
# Authentication:

#LoginGraceTime 2m
 #PermitRootLogin Yes
#StrictModes yes
#MaxAuthTries 6
.
.

Change the line #PermitRootLogin yes to PermitRootLogin no and save the file.

After changing the line Authentication block will look like below

.
.
# Authentication:

#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
.
.
  • These changes will come into effect when the ssh service will be restarted. To restart the ssh service, use any command shown below:
[root@TestServer ~]# /etc/init.d/sshd restart

Stopping sshd:         [ OK ]

Starting sshd:           [ OK ]

OR

[root@TestServer ~]# service sshd restart

Stopping sshd:          [ OK ]
Starting sshd:            [ OK ]
  • Now, you will not be allowed to ssh this server as a root user. It will show the access denied as shown below:
login as: root
Using keyboard-interactive authentication.
Password:
 Access denied

Create a new user in Linux and switch to root whenever required:

  • Create a new user in Linux, here I have created a user dbappweb and changed the password of the user
[root@TestServer ~]# useradd dbappweb

[root@TestServer ~]# passwd dbappweb

Changing password for dbappwebl

New password:

Re-enter new password:
Passwd successfully changed
  • Now login through user dbappweb and after that switch to the root user.
login as: dbappweb
dbappweb@10.10.0.10's password:
Last login: Thu Jul 20 10:04:40 2017 from 172.10.10.11
[dbappweb@TestServer ~]$ su - root
Password:
[root@TestServer ~]#

Note: I have done the above steps on the RHEL 5.8.

Related Posts:

  • How to Disable Root SHH Login in HP-UX?
Prev Article
Next Article
Tags:HP-UX Linux SSH Sys Admin

No Responses

  1. Pingback: How to Find Out RHEL 6 / RHEL 7 Kernel Version - DbAppWeb.com
  2. Pingback: How to Find Last Patch Date of RHEL Servers - DbAppWeb.com

Leave a Reply Cancel Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Popular
  • Recent

Categories

  • Android (2)
  • Blogger (16)
  • Domain and Hosting (1)
  • Hardware Issues (7)
  • HP-UX (55)
  • HPE Data Protector (9)
  • IBM Lotus Notes (2)
  • IBM WebSphere Application Server (16)
  • Internet Tips & Tricks (15)
  • iOS (8)
  • JBoss/WildFly Application Server (2)
  • Linux (76)
  • macOS (15)
  • Microsoft Windows (31)
  • News and Updates (11)
  • Oracle Database (5)
  • SSL/TLS (1)
  • Storage Servers (23)
  • Tools/Softwares (1)
  • VMware ESXi (17)
  • Web Servers (14)
  • WordPress (5)

Archives

DbAppWeb.com

Solution of Database, Application and Web Server Problems

About DbAppWeb.com

One Stop Solution for Database Server, Application Server and Web Server Problems.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

DbAppWeb on Social Media

Copyright © 2026 DbAppWeb.com
Terms and Conditions   Theme by MyThemeShop.com