Forge Home

ssh_hardening

Installs and configures OpenSSH with hardening

124,207 downloads

87,776 latest version

3.8 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 1.0.5 (latest)
  • 1.0.4
  • 1.0.3
  • 1.0.2
  • 1.0.1
  • 1.0.0
  • 0.1.1
  • 0.1.0
released May 9th 2015

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'hardening-ssh_hardening', '1.0.5'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add hardening-ssh_hardening
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install hardening-ssh_hardening --version 1.0.5

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

hardening/ssh_hardening — version 1.0.5 May 9th 2015

Puppet SSH hardening

Puppet Forge Build Status Gitter Chat

Description

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

Requirements

  • Puppet
  • Puppet modules: saz/ssh (>= 2.3.6), puppetlabs/stdlib (>= 4.2.0)

Parameters

  • ipv6_enabled = false - true if IPv6 is needed
  • cbc_required = false - true if CBC for ciphers is required. This is usually only necessary, if older M2M mechanism need to communicate with SSH, that don't have any of the configured secure ciphers enabled. CBC is a weak alternative. Anything weaker should be avoided and is thus not available.
  • weak_hmac = false - true if weaker HMAC mechanisms are required. This is usually only necessary, if older M2M mechanism need to communicate with SSH, that don't have any of the configured secure HMACs enabled.
  • weak_kex = false - true if weaker Key-Exchange (KEX) mechanisms are required. This is usually only necessary, if older M2M mechanism need to communicate with SSH, that don't have any of the configured secure KEXs enabled.
  • allow_root_with_key = false - false to disable root login altogether. Set to true to allow root to login via key-based mechanism.
  • ports = [ 22 ] - ports to which ssh-server should listen to and ssh-client should connect to
  • listen_to = [ "0.0.0.0" ] - one or more ip addresses, to which ssh-server should listen to. Default is empty, but should be configured for security reasons!
  • remote_hosts - one or more hosts, to which ssh-client can connect to. Default is empty, but should be configured for security reasons!
  • allow_tcp_forwarding = false - set to true to allow TCP forwarding
  • allow_agent_forwarding = false - set to true to allow Agent forwarding
  • use_pam = false to disable pam authentication
  • client_options = {} - set values in the hash to override the module's settings
  • server_options = {} - set values in the hash to override the module's settings

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',
  },
}

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 negotation 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.