Linux - Security This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
06-01-2006, 10:50 PM
|
#1
|
LQ Newbie
Registered: Apr 2006
Posts: 8
Rep:
|
Allowing root login to ssh only on LAN
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" ?
|
|
|
06-02-2006, 01:29 AM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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.
3) nope.
|
|
|
06-02-2006, 02:11 AM
|
#3
|
LQ Newbie
Registered: May 2006
Posts: 20
Rep:
|
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
|
|
|
06-02-2006, 02:16 AM
|
#4
|
LQ Newbie
Registered: May 2006
Posts: 20
Rep:
|
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
let's try it !
|
|
|
06-02-2006, 02:28 AM
|
#5
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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.
|
|
|
06-02-2006, 05:42 AM
|
#6
|
LQ Newbie
Registered: May 2006
Posts: 20
Rep:
|
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
|
|
|
07-17-2006, 09:42 PM
|
#7
|
LQ Guru
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678
Rep:
|
I finally got around to playing with this, and although I had a few problems with huanvnn's first solution, a little digging led me to try
AllowUsers *@192.168.1.* ok_external_user@*
where 192.168.1 is my internal subnet.
Works just fine - only lets ok_external_user to log in from anywhere other than the local subnet, and any valid user from the local.
Rgds
Bill
|
|
|
All times are GMT -5. The time now is 11:53 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|