LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 02-15-2008, 07:46 AM   #1
cizzi
Member
 
Registered: Jun 2001
Distribution: Gentoo
Posts: 153

Rep: Reputation: 19
how to limit ssh by user and ip


How can I limit a certain user to login from a certain set of IPs only?

I tried this:

AllowUsers "user@\i192.*"

but cant get it to work.. i put it in /etc/ssh/sshd_config and restarted the server...

What am I doing wrong?
 
Old 02-15-2008, 09:35 AM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by cizzi
AllowUsers "user@\i192.*"
Could you explain that pattern? I haven't tested this, but from the manpages I'd expect it to be:
AllowUsers user@192.*
 
Old 02-15-2008, 11:16 AM   #3
cizzi
Member
 
Registered: Jun 2001
Distribution: Gentoo
Posts: 153

Original Poster
Rep: Reputation: 19
Thanks that worked, however I'd also like to add AllowGroups users to allow users from the users groups to login, when you use AllowUsers with AllowGroups I read that AllowUsers takes precedence thus ignoring AllowGroups. The other option is to add all the users one at a time in AllowUsers.. any other ideas?
 
Old 02-15-2008, 11:29 AM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
I don't understand your full requirements. You want all users in a group you specify to be able to login (from a specific subnet)? Are there also users outside of the group that need access?
 
Old 02-15-2008, 11:39 AM   #5
cizzi
Member
 
Registered: Jun 2001
Distribution: Gentoo
Posts: 153

Original Poster
Rep: Reputation: 19
I want myself to be able to login with ssh locally which works with:

AllowUsers myuser@192.*

And I want my regular users to login (they are all part of the users group), so I tried this:

AllowGroups users (from any subnet on the internet)

However, when I use both AllowUsers and AllowGroups, the users cannot login.

Last edited by cizzi; 02-15-2008 at 11:43 AM.
 
Old 02-15-2008, 12:32 PM   #6
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Ah. That's going to be a problem. From the sshd_config(5) manpages:
Quote:
The allow/deny directives are processed in the following
order: DenyUsers, AllowUsers, DenyGroups, and finally
AllowGroups.
To solve this you can a) run two sshd instances (that'll require some knowledge about your distro's rc/init scripts); b) use only the AllowGroups directive, and add yourself to that group.

There may be other ideas too.
 
Old 02-15-2008, 03:18 PM   #7
cizzi
Member
 
Registered: Jun 2001
Distribution: Gentoo
Posts: 153

Original Poster
Rep: Reputation: 19
Allright I got it to work with your suggestions. Thank you!

Last edited by cizzi; 02-15-2008 at 03:49 PM.
 
  


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
Limit multiple SSH login by the same user yanziqiang Linux - Security 10 12-22-2007 05:06 AM
Limit user via SSH (AllowedUser) but how NOT to affect vsftpd? Swakoo Linux - Security 13 06-25-2007 09:33 AM
SSH file size limit? kstringham Linux - Networking 2 11-20-2006 10:45 AM
ssh limit setting tuxhats Linux - Networking 4 07-18-2006 02:42 PM
limit access to SSH server by IP nick1 SUSE / openSUSE 6 03-29-2005 04:36 PM

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

All times are GMT -5. The time now is 09:38 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