Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
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.
I want to disable root login over the internet for ssh, and allow root over lan for ssh because I need it to configure/edit some things since the machine does not have a keyboard.
1) Is there a way to only enable root login if it's coming from a LAN computer? (Meaning an ip of the same subnet, else if it's the interent, disallow root)
2) My lan uses a router to connect to the internet, so maybe I can disable root login if the source is from my router's IP? (which would drop any internet root attempts?)
3) Will this also prevent someone over the internet from logging in as a regular user, and then using: "su root" ?
1) no i do not believe so. you have two seperate application layers there. you can use tcpwrappers as a generic solution to prevent certain sources connecting to certain local services, but this would only take you to a point where no one would be able to log in remotely from the net.
2) ssh itself has an option "PermitRootLogin" which stops root logging in at all. this is something that you should *really* be considering as a matter of course, but this option will block access to the root user from everywhere always.
hi monkeyfoo,i had a problem as you ,and i solved them by this way :
in the file configuration of server sshd : /etc/sshd/sshd_config
you add 2 keys
ALLOWUSERS
DENYUSERS
in allowusers you write your LAN and in your denyusers you write the blocked address
the syntax that
ALLOWUSERS user@hostname
DENYUSERS user@hostname
for example
ALLOWUSERS root@192.168.0.*
DENYUSERS root@! 192.168.0.*
in this way i mean that my LAN IP from 192.168.0.1--192.168.168.0.254
try it
oh i have the second solution :
in the file /etc/sshd/sshd_config
you should see at the line : listen address
with default your sshd server will listen with every interface.for example you have 2 interface : 1 interface (your public ip to connect to ISP) and 1 interface connected to LAN .
in this line you should modify and add only your interface connected to LAN
and from now on sshd only accept and reply requests from your LAN
example : my address in LAN 192.168.0.1 in the line listen address i wrote
listen address : 192.168.0.1
hmmm, once again i'm shown to be lacking.... can't see many references to defining an AllowUsers subnet, only domains and hosts, but it may well be possible to define a network range, and if not domain name should still be good enough.
to more detail about sshd please run the man page of sshd
commnand : man /etc/sshd/config_sshd
there you will see about the key ALLOWUSERS
with default the ALLOWUSERS isn't added in /etc/sshd/config_sshd and you should manually add it
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.