[SOLVED] forcing root login using keys instead of password
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
In your /etc/ssh/sshd_config file make sure that PublicKeyAuthentication is "yes" and PasswordAuthentication and UsePAM are set to "no". There might be another directive or two that I'm not remembering off the top of my head. Try it and if it let's you in without a key, then there is another directive to disable.
Ignore that last post. I obviously didn't read the question very carefully.
There might be a way to do what you're asking but I think a better solution would be to disable root login and give sudo access to specific users who need admin access.
I consider remote root login a risk (with or without keys). Rather create a user that knows the root password, let him/her login with his/her credentials and use 'su -' to gain root privileges.
In your /etc/ssh/sshd_config file make sure that PublicKeyAuthentication is "yes" and PasswordAuthentication and UsePAM are set to "no". There might be another directive or two that I'm not remembering off the top of my head. Try it and if it let's you in without a key, then there is another directive to disable.
There is the option in /etc/ssh/sshd_config:
Code:
PermitRootLogin without-password
Contrary to the first impression you get from this option, it will limit root logins to be done by public keys only. In addition it could be limited to be allowed only from certain machines with an AllowUsers option in addition therein.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.