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 11-04-2010, 07:15 PM   #1
gnaray2
LQ Newbie
 
Registered: Nov 2010
Posts: 3

Rep: Reputation: 0
Restricting SSH access based on boolean ip expression


Hello,

I understand we can restrict SSH access based on ip address(s) using either tcpwrapper or iptable rules. I have an use case where SSH access is defined by a boolean expression - something like:

ssh.access "host=10.56.7.1 or (host=10.56.7.2 and host=10.56.7.3)"

10.56.7.1 - Allow (above expression evaluates to true)
10.56.7.2 - Deny (above expression evaluates to false)
10.56.7.3 - Deny (above expression evaluates to false)

Is there any simpler way to do this ? One way I can think of is to modify the SSH code and for each incoming ip address, evaluate the above expression, but I don't think that is a good way to do this.

Any help appreciated.
 
Old 11-04-2010, 08:01 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
How do you make a connection from more than one IP at once?
 
Old 11-05-2010, 12:22 AM   #3
gnaray2
LQ Newbie
 
Registered: Nov 2010
Posts: 3

Original Poster
Rep: Reputation: 0
No, it is going to be just from one ip. When the connection is made, it has to be evaluated against the Boolean expression.

To give another use case, the user can allow access from any ip in the 10.22.9 subnet except 10.22.9.170 and 10.22.9.169 using the following rule:
ssh.access "host=10.22.9.1/24 and host!=10.22.9.170,10.22.9.169"
 
Old 11-05-2010, 05:18 AM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by gnaray2 View Post
No, it is going to be just from one ip. When the connection is made, it has to be evaluated against the Boolean expression.

To give another use case, the user can allow access from any ip in the 10.22.9 subnet except 10.22.9.170 and 10.22.9.169 using the following rule:
ssh.access "host=10.22.9.1/24 and host!=10.22.9.170,10.22.9.169"
With iptables that would go like this (example):
Code:
iptables -A INPUT -p TCP --dport 22 -s 10.22.9.170 -j DROP
iptables -A INPUT -p TCP --dport 22 -s 10.22.9.169 -j DROP
iptables -A INPUT -p TCP --dport 22 -s 10.22.9.0/24 -j ACCEPT
 
  


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
[SOLVED] [bash] assign boolean expression to variable hashbang#! Programming 10 08-16-2009 08:44 AM
Restricting access to a port based upon uid? Termina Linux - Security 2 08-20-2006 10:32 AM
can some one explain me this java boolean expression amolgupta Programming 4 05-11-2006 04:54 AM
Restricting SSH access by IP sooner5150 Linux - Security 3 11-18-2004 11:09 AM
Restricting SSH Access ErocM Linux - Security 4 02-20-2004 10:52 AM

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

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