Skip to content

Commit

Permalink
Merge f23011f into e071016
Browse files Browse the repository at this point in the history
  • Loading branch information
arlimus committed Feb 5, 2015
2 parents e071016 + f23011f commit 89ab680
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
2 changes: 2 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@
default['ssh']['allow_tcp_forwarding'] = false # sshd
default['ssh']['allow_agent_forwarding'] = false # sshd
default['ssh']['use_pam'] = false # sshd
# set this to nil to let us detect the attribute based on the node platform
default['ssh']['use_privilege_separation'] = nil
46 changes: 46 additions & 0 deletions libraries/use_privilege_separation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# encoding: utf-8
#
# Cookbook Name:: ssh-hardening
# Library:: use_privilege_separation
#
# Copyright 2015, Dominik Richter
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

class Chef
class Recipe
class UsePrivilegeSeparation
def self.get(node)
# define cipher set
ps53 = "yes"
ps59 = "sandbox"
ps = ps59

# ubuntu 12.04 and newer has ssh 5.9+

# redhat/centos/oracle 6.x has ssh 5.3
if node['platform_family'] == 'rhel'
ps = ps53

# debian 7.x and newer has ssh 5.9+
elsif node['platform'] == 'debian' && node['platform_version'].to_f <= 6
ps = ps53
end

Chef::Log.info("UsePrivilegeSeparation: #{ps}")
ps
end
end
end
end
3 changes: 2 additions & 1 deletion recipes/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
variables(
mac: SshMac.get_macs(node, node['ssh']['server']['weak_hmac']),
kex: SshKex.get_kexs(node, node['ssh']['server']['weak_kex']),
cipher: SshCipher.get_ciphers(node, node['ssh']['server']['cbc_required'])
cipher: SshCipher.get_ciphers(node, node['ssh']['server']['cbc_required']),
use_priv_sep: node['ssh']['use_privilege_separation'] || UsePrivilegeSeparation.get(node)
)
notifies :restart, 'service[sshd]'
end
Expand Down
2 changes: 1 addition & 1 deletion templates/default/opensshd.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ KexAlgorithms <%= @kex %>

# Secure Login directives.
UseLogin no
UsePrivilegeSeparation yes
UsePrivilegeSeparation <%= @use_priv_sep %>
PermitUserEnvironment no
LoginGraceTime 30s
MaxAuthTries 2
Expand Down

0 comments on commit 89ab680

Please sign in to comment.