Red Hat Enterprise Linux - Allow Root Login From a Specific IP Address Only

Title: Red Hat Enterprise Linux - Allow Root Login From a Specific IP Address Only
Object Name: mmr_kc-0119626
Document Type: Support Information
Original owner: KCS - Linux
Disclosure level: Public
Version state: final
Environment
FACT:Red Hat Enterprise Linux
Questions/Symptoms
GOAL:Restrict root SSH login to a single IP address
Cause
CAUSE:
Answer/Solution
FIX:This can be accomplished with the use of PAM access controls.  There are two steps:

1. In /etc/pam.d/sshd, add the following line:

account    required     pam_access.so


2. In /etc/security/access.conf, set up root access controls by adding the following two lines at the end of the file:

+ : root : IP_address
- : root : ALL


Replace "IP_address" with the IP address of the system from which root logins will be allowed.  Note that there is a space before and after each colon.  The first line allows root access from the specified IP address; the second line denies root access from everywhere else.  The order of these two lines is significant.  This will take effect immediately with no need to reboot or restart any daemons.


Login attempts that are blocked by this check will be logged in /var/log/secure:

Jul 15 16:51:42 hostname sshd[18241]: fatal: Access denied for user root by PAM account configuration

This method of access control is very flexible and powerful.  For example, if you should need to add a second allowed host at some point in the future, simply add its IP address to the first line:

+ : root : IP_address_1 IP_address_2
- : root : ALL


There are many other options, which are well documented within the access.conf file itself or its reference page.
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
How to convert RAW image to VDI and otherwise
Viewed 16276 times since Wed, Oct 3, 2018
how to list all hard disks in linux from command line
Viewed 5687 times since Mon, Jan 28, 2019
OpenSSL – sprawdzanie czy klucz pasuje do certyfikatu
Viewed 3602 times since Thu, May 24, 2018
Linux: Disks diagnostic using smartctl
Viewed 16319 times since Wed, Jul 25, 2018
Installing and Configuring stunnel on CentOS 6
Viewed 5069 times since Fri, Sep 28, 2018
20 Linux YUM (Yellowdog Updater, Modified) Commands for Package Management YUM
Viewed 12272 times since Thu, Oct 25, 2018
LVM: Reduce root PV/VG
Viewed 6296 times since Sat, Jun 2, 2018
HowTo: The Ultimate Logrotate Command Tutorial with 10 Examples
Viewed 7448 times since Fri, Nov 30, 2018
YUM CRON Enabling automatic updates in Centos 7 and RHEL 7
Viewed 12941 times since Fri, Oct 26, 2018
Watchdog script to keep an application running
Viewed 20534 times since Tue, Jul 31, 2018