LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Fedora (https://www.linuxquestions.org/questions/fedora-35/)
-   -   Allow root access via PAM (https://www.linuxquestions.org/questions/fedora-35/allow-root-access-via-pam-705185/)

fw12 02-16-2009 05:54 PM

Allow root access via PAM
 
I need to disable root access. However, I need root access from a specific IP address.

I disabled root access as follows:

# vim /etc/ssh/sshd_config
Changed:
PermitRootLogin yes
to:
PermitRootLogin no

# /etc/rc.d/init.d/sshd restart

The above disabled root access for good.
Next, I used PAM to allow access from a specific IP

# vim /etc/security/access.conf

I appended the following lines:

+ : root : 10.0.0.254
+ : root : 127.0.0.1
- : root : ALL

Finally,

# vim /etc/pam.d/sshd

I appended the following entry

account required pam_access.so

With the above config, I'm still getting "permission denied" when I try to login via ssh from 10.0.0.254

What did I miss?

kenneho 02-17-2009 01:55 AM

I'm definately not an expert on PAM, but just a thought: If the "PermitRootLogin no" gets evaluated before PAM, it doesn't matter how you set up your PAM files. How about setting this option back to "yes", and control everything from PAM?

lazlow 02-17-2009 02:32 AM

It is probably better to remote in as a user and then su - (su space dash) into root.

pcunix 02-17-2009 08:13 AM

Quote:

Originally Posted by lazlow (Post 3446545)
It is probably better to remote in as a user and then su - (su space dash) into root.

No, you are wrong.

It's not "probably better". It's ALWAYS better.

And it could be even better to use sudo rather than "su -".


All times are GMT -5. The time now is 08:58 AM.