Operating System - Linux
1829428 Members
2889 Online
109991 Solutions
New Discussion

prevent ssh from login as root

 
SOLVED
Go to solution
Rick Garland
Honored Contributor

prevent ssh from login as root

Hi all:

Got RedHat versions 7 and above.
Received info on pam/su stuff to prevent non-wheel group members from becoming root. Have setup the securetty file.

I also have ssh 3.5.1p1 installed on the Linux systems and on HPUX 11.00.

I am still able to ssh root@linux from the HP system. I need to stop this from happening. I want to block ssh root@linux and force the users to login as themselves 1st then become root (if a member of wheel).

How can I stop ssh root@linux?

Many thanks!
3 REPLIES 3
Steven E. Protter
Exalted Contributor

Re: prevent ssh from login as root

My first thought would be to eliminate this direcotry:

$HOME/.ssh

Or just change the permissions to 000

Just do that on any box you want to stop ssh root logins in roots home directory.

I think at that point you will get authentication errors if you try and ssh as root.

If you exchange public keys between the machines, you can safely run ssh between boxes. I'm sure you have a reason for doing this, Secure Shell is safe for root. As far as I know anyway.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Rick Garland
Honored Contributor

Re: prevent ssh from login as root

Did some digging, found it.

In the /etc/ssh/sshd_config file is an entry for PermitRootLogin - set this value to no.

Vincent Woo
Occasional Advisor
Solution

Re: prevent ssh from login as root

change /etc/ssh/sshd_config

#PermitRootLogin yes (already comment out)

add this line
PermitRootLogin no
pierre