-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A simple defined type that allows for creating match rules and applying specific configuration to those sessions.
- Loading branch information
Zach Leslie
committed
Feb 7, 2015
1 parent
925d8bc
commit cc0a723
Showing
3 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Define: ssh::server::match | ||
# | ||
# Apply a set of keywords to matching tokens. | ||
# | ||
# Examples: | ||
# | ||
# ssh::server::match { 'Group wheel': | ||
# forcecommand => '/usr/sbin/login_duo' | ||
# } | ||
# | ||
# ssh::server::match { 'User bob': | ||
# forcecommand => '/sbin/nologin' | ||
# } | ||
# | ||
define ssh::server::match ( | ||
$allowagentforwarding = undef, | ||
$allowgroups = undef, | ||
$allowtcpforwarding = undef, | ||
$allowusers = undef, | ||
$authenticationmethods = undef, | ||
$authorizedkeyscommand = undef, | ||
$authorizedkeyscommanduser = undef, | ||
$authorizedkeysfile = undef, | ||
$authorizedprincipalsfile = undef, | ||
$banner = undef, | ||
$chrootdirectory = undef, | ||
$denygroups = undef, | ||
$denyusers = undef, | ||
$forcecommand = undef, | ||
$gatewayports = undef, | ||
$gssapiauthentication = undef, | ||
$hostbasedauthentication = undef, | ||
$hostbasedusesnamefrompacketonly = undef, | ||
$kbdinteractiveauthentication = undef, | ||
$kerberosauthentication = undef, | ||
$maxauthtries = undef, | ||
$maxsessions = undef, | ||
$passwordauthentication = undef, | ||
$permitemptypasswords = undef, | ||
$permitopen = undef, | ||
$permitrootlogin = undef, | ||
$permittty = undef, | ||
$permittunnel = undef, | ||
$permituserrc = undef, | ||
$pubkeyauthentication = undef, | ||
$rekeylimit = undef, | ||
$rhostsrsaauthentication = undef, | ||
$rsaauthentication = undef, | ||
$x11displayoffset = undef, | ||
$x11forwarding = undef, | ||
$x11uselocalhost = undef, | ||
) { | ||
|
||
include ssh::params | ||
include ssh::server | ||
|
||
$sshd_config = $ssh::params::sshd_config | ||
|
||
$valid_token = [ | ||
'User', | ||
'Group', | ||
'Host', | ||
'Localaddress', | ||
'Localport', | ||
'Address', | ||
] | ||
|
||
$valid_keywords = [ | ||
'AllowAgentForwarding', | ||
'AllowGroups', | ||
'AllowTcpForwarding', | ||
'AllowUsers', | ||
'AuthenticationMethods', | ||
'AuthorizedKeysCommand', | ||
'AuthorizedKeysCommandUser', | ||
'AuthorizedKeysFile', | ||
'AuthorizedPrincipalsFile', | ||
'Banner', | ||
'ChrootDirectory', | ||
'DenyGroups', | ||
'DenyUsers', | ||
'ForceCommand', | ||
'GatewayPorts', | ||
'GSSAPIAuthentication', | ||
'HostbasedAuthentication', | ||
'HostbasedUsesNameFromPacketOnly', | ||
'KbdInteractiveAuthentication', | ||
'KerberosAuthentication', | ||
'MaxAuthTries', | ||
'MaxSessions', | ||
'PasswordAuthentication', | ||
'PermitEmptyPasswords', | ||
'PermitOpen', | ||
'PermitRootLogin', | ||
'PermitTTY', | ||
'PermitTunnel', | ||
'PermitUserRC', | ||
'PubkeyAuthentication', | ||
'RekeyLimit', | ||
'RhostsRSAAuthentication', | ||
'RSAAuthentication', | ||
'X11DisplayOffset', | ||
'X11Forwarding', | ||
'X11UseLocalHost' | ||
] | ||
|
||
concat::fragment { "sshd_config_match-${name}": | ||
target => $sshd_config, | ||
content => template('ssh/sshd_config-match.erb'), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
require 'spec_helper' | ||
|
||
describe 'ssh::server::match' do | ||
let(:title) { 'Group nerds' } | ||
it { should contain_class('ssh::server') } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Match <%= @name %> | ||
<%- | ||
@valid_keywords.map do |kw| | ||
next if scope[kw.downcase] == :undef | ||
-%> | ||
<%= [kw,scope[kw.downcase]].join(' ') %> | ||
<%- | ||
end | ||
-%> | ||
|