Home

Awesome

Puppet SSH hardening

Puppet Forge Build Status Gitter Chat

Description

This Puppet module provides secure ssh-client and ssh-server configurations.

Requirements

Parameters

Usage

After adding this module, you can use the class:

class { 'ssh_hardening': }

This will install ssh-server and ssh-client. You can alternatively choose only one via:

class { 'ssh_hardening::server': }
class { 'ssh_hardening::client': }

You should configure core attributes:

class { 'ssh_hardening::server':
  "listen_to" : ["10.2.3.4"]
}

The default value for listen_to is 0.0.0.0. It is highly recommended to change the value.

Overwriting default options

Default options will be merged with options passed in by the client_options and server_options parameters. If an option is set both as default and via options parameter, the latter will win.

The following example will enable X11Forwarding, which is disabled by default:

class { 'ssh_hardening':
  server_options => {
    'X11Forwarding' => 'yes',
  },
}

Local Testing

For local testing you can use vagrant and Virtualbox of VMWare to run tests locally. You will have to install Virtualbox and Vagrant on your system. See Vagrant Downloads for a vagrant package suitable for your system. For all our tests we use test-kitchen. If you are not familiar with test-kitchen please have a look at their guide.

Next install test-kitchen:

# Install dependencies
gem install bundler
bundle install

# Fetch tests
bundle exec thor kitchen:fetch-remote-tests

# Do lint checks
bundle exec rake lint

# Do spec checks
bundle exec rake spec

# fast test on one machine
bundle exec kitchen test default-ubuntu-1204

# test on Debian-based machines
bundle exec kitchen test

# for development
bundle exec kitchen create default-ubuntu-1204
bundle exec kitchen converge default-ubuntu-1204

For more information see test-kitchen

FAQ / Pitfalls

I can't log into my account. I have registered the client key, but it still doesn't let me it.

If you have exhausted all typical issues (firewall, network, key missing, wrong key, account disabled etc.), it may be that your account is locked. The quickest way to find out is to look at the password hash for your user:

sudo grep myuser /etc/shadow

If the hash includes an !, your account is locked:

myuser:!:16280:7:60:7:::

The proper way to solve this is to unlock the account (passwd -u myuser). If the user doesn't have a password, you should can unlock it via:

usermod -p "*" myuser

Alternatively, if you intend to use PAM, you enabled it via use_pam = true. PAM will allow locked users to get in with keys.

Why doesn't my application connect via SSH anymore?

Always look into log files first and if possible look at the negotiation between client and server that is completed when connecting.

We have seen some issues in applications (based on python and ruby) that are due to their use of an outdated crypto set. This collides with this hardening module, which reduced the list of ciphers, message authentication codes (MACs) and key exchange (KEX) algorithms to a more secure selection.

If you find this isn't enough, feel free to activate cbc_required for ciphers, weak_hmac for MACs, and weak_kex for KEX.

Contributors + Kudos

License and Author

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.