Bug 756861

Summary: sshd_config Match parameter doesn't seem to work with negated address patterns
Product: Red Hat Enterprise Linux 6 Reporter: Gerardo Arceri <gea>
Component: opensshAssignee: Petr Lautrbach <plautrba>
Status: CLOSED NOTABUG QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.1CC: pvrabec
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-08 15:14:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Gerardo Arceri 2011-11-24 21:49:12 UTC
Description of problem:
While trying to setup chrooted ssh for certain users i found out that (at least) the Address Match parameter will ignore negated patterns (!192.168.0.0/32)
If you use:

Match User sshtest Address 192.168.0.1/32
ForceCommand /sbin/nologin

It will work (only users logging in from 192.168.0.1 will get kicked off

but if you attempt to negate the address pattern

Match User sshtest Address !192.168.0.1/32
ForceCommand /sbin/nologin


It will not work




Version-Release number of selected component (if applicable):
openssh-server-5.3p1-52.el6_1.2.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Setup ssh with the configuration shown above using a negated address pattern
2. Attempt to connect
3. Check results.
  
Actual results:
Rule should match as described in the sshd_config manpage.
" The match patterns may consist of single entries or comma-separated lists and may use the wildcard and negation operators described in the PATTERNS section of ssh_config(5)."



Expected results:
The negated pattern takes effect

Additional info:

Comment 2 Petr Lautrbach 2011-12-08 15:14:42 UTC
"A pattern-list is a comma-separated list of patterns.  Patterns within  pattern-lists may be negated by preceding them with an exclamation mark(‘!’)."

So you can negate only listed patterns, correct setting is:

Match User sshtest Address !192.168.0.1/32,*
  ForceCommand /sbin/nologin