LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 06-01-2006, 10:50 PM   #1
monkeyfoo
LQ Newbie
 
Registered: Apr 2006
Posts: 8

Rep: Reputation: 0
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" ?
 
Old 06-02-2006, 01:29 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
Old 06-02-2006, 02:11 AM   #3
huanvnn
LQ Newbie
 
Registered: May 2006
Posts: 20

Rep: Reputation: 0
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
 
Old 06-02-2006, 02:16 AM   #4
huanvnn
LQ Newbie
 
Registered: May 2006
Posts: 20

Rep: Reputation: 0
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 !
 
Old 06-02-2006, 02:28 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
Old 06-02-2006, 05:42 AM   #6
huanvnn
LQ Newbie
 
Registered: May 2006
Posts: 20

Rep: Reputation: 0
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
 
Old 07-17-2006, 09:42 PM   #7
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
safe guarding your system by not allowing anyone to login as root abhis_mail2002 Fedora 6 05-14-2006 02:58 AM
disable root login with ssh linuxtesting2 Slackware 3 02-16-2005 12:33 PM
ssh only allow root login chongluo Linux - Newbie 1 10-28-2004 08:51 AM
Only root can login via ssh cmisip Linux - Security 5 04-26-2003 05:16 AM
Anyway to use rsync ssh without allowing root access? ifm Linux - Security 0 06-12-2002 01:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 09:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration