File tree 4 files changed +51
-2
lines changed
4 files changed +51
-2
lines changed Original file line number Diff line number Diff line change 59
59
default [ 'ssh' ] [ 'allow_tcp_forwarding' ] = false # sshd
60
60
default [ 'ssh' ] [ 'allow_agent_forwarding' ] = false # sshd
61
61
default [ 'ssh' ] [ 'use_pam' ] = false # sshd
62
+ # set this to nil to let us detect the attribute based on the node platform
63
+ default [ 'ssh' ] [ 'use_privilege_separation' ] = nil
Original file line number Diff line number Diff line change
1
+ # encoding: utf-8
2
+ #
3
+ # Cookbook Name:: ssh-hardening
4
+ # Library:: use_privilege_separation
5
+ #
6
+ # Copyright 2015, Dominik Richter
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ class Chef
22
+ class Recipe
23
+ class UsePrivilegeSeparation
24
+ def self . get ( node )
25
+ # define cipher set
26
+ ps53 = 'yes'
27
+ ps59 = 'sandbox'
28
+ ps = ps59
29
+
30
+ # ubuntu 12.04 and newer has ssh 5.9+
31
+
32
+ # redhat/centos/oracle 6.x has ssh 5.3
33
+ if node [ 'platform_family' ] == 'rhel'
34
+ ps = ps53
35
+
36
+ # debian 7.x and newer has ssh 5.9+
37
+ elsif node [ 'platform' ] == 'debian' && node [ 'platform_version' ] . to_f <= 6
38
+ ps = ps53
39
+ end
40
+
41
+ Chef ::Log . info ( "UsePrivilegeSeparation: #{ ps } " )
42
+ ps
43
+ end
44
+ end
45
+ end
46
+ end
Original file line number Diff line number Diff line change 92
92
variables (
93
93
mac : SshMac . get_macs ( node , node [ 'ssh' ] [ 'server' ] [ 'weak_hmac' ] ) ,
94
94
kex : SshKex . get_kexs ( node , node [ 'ssh' ] [ 'server' ] [ 'weak_kex' ] ) ,
95
- cipher : SshCipher . get_ciphers ( node , node [ 'ssh' ] [ 'server' ] [ 'cbc_required' ] )
95
+ cipher : SshCipher . get_ciphers ( node , node [ 'ssh' ] [ 'server' ] [ 'cbc_required' ] ) ,
96
+ use_priv_sep : node [ 'ssh' ] [ 'use_privilege_separation' ] || UsePrivilegeSeparation . get ( node )
96
97
)
97
98
notifies :restart , 'service[sshd]'
98
99
end
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ KexAlgorithms <%= @kex %>
86
86
87
87
# Secure Login directives.
88
88
UseLogin no
89
- UsePrivilegeSeparation yes
89
+ UsePrivilegeSeparation <%= @use_priv_sep %>
90
90
PermitUserEnvironment no
91
91
LoginGraceTime 30s
92
92
MaxAuthTries 2
You can’t perform that action at this time.
0 commit comments