Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Created February 21, 2011 11:14
Show Gist options
  • Select an option

  • Save mrchrisadams/836939 to your computer and use it in GitHub Desktop.

Select an option

Save mrchrisadams/836939 to your computer and use it in GitHub Desktop.
default[:sshd][:permit_root_login] = "no"
default[:sshd][:rsa_authentication] = "no"
default[:sshd][:pubkey_authentication] = "yes"
default[:sshd][:password_authentication] = "no"
default[:sshd][:pam_authentication] = "no"
default[:sshd][:allow_tcp_forwarding] = "yes"
default[:sshd][:x11_forwarding] = "yes"
default[:sshd][:permit_user_environment] = "yes"
default[:sshd][:banner] = "/etc/banner"
#
# Cookbook Name:: openssh
# Recipe:: default
#
# Copyright 2008-2009, Opscode, Inc.
#
# 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.
#
packages = case node[:platform]
when "centos","redhat","fedora"
%w{openssh-clients openssh}
when "arch"
%w{openssh}
else
%w{openssh-client openssh-server}
end
packages.each do |pkg|
package pkg
end
service "ssh" do
case node[:platform]
when "centos","redhat","fedora","arch"
service_name "sshd"
else
service_name "ssh"
end
supports value_for_platform(
"debian" => { "default" => [ :restart, :reload, :status ] },
"ubuntu" => {
"8.04" => [ :restart, :reload ],
"default" => [ :restart, :reload, :status ]
},
"centos" => { "default" => [ :restart, :reload, :status ] },
"redhat" => { "default" => [ :restart, :reload, :status ] },
"fedora" => { "default" => [ :restart, :reload, :status ] },
"arch" => { "default" => [ :restart ] },
"default" => { "default" => [:restart, :reload ] }
)
action [ :enable, :start ]
end
template "banner" do
path "/etc/banner"
source "banner.erb"
owner "root"
group "root"
mode 0600
end
template "sshd_config" do
path "/etc/ssh/sshd_config"
source "sshd_config.erb"
owner "root"
group "root"
mode 0600
notifies :restart, resources(:service => "ssh"), :immediately
end
# $OpenBSD: sshd_config,v 1.73 2005/12/06 22:38:28 reyk Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options change a
# default value.
#Port 22
#Protocol 2,1
Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768
# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
PermitRootLogin <%= node[:sshd][:permit_root_login] %>
#StrictModes yes
#MaxAuthTries 6
RSAAuthentication <%= node[:sshd][:rsa_authentication] %>
PubkeyAuthentication <%= node[:sshd][:pubkey_authentication] %>
#AuthorizedKeysFile .ssh/authorized_keys
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication <%= node[:sshd][:password_authentication] %>
PermitEmptyPasswords no
# Change to no to disable s/key passwords
ChallengeResponseAuthentication no
# Kerberos options
KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication mechanism.
# depending on your PAM configuration, this may bypass the setting of
# PasswordAuthentication, PermitEmptyPasswords, and
# "PermitRootLogin without-password". If you just want the PAM account and
# session checks to run without PAM authentication, then enable this but set
# ChallengeResponseAuthentication=no
UsePAM <%= node[:sshd][:pam_authentication] %>
# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL
AllowTcpForwarding <%= node[:sshd][:allow_tcp_forwarding] %>
#GatewayPorts no
#X11Forwarding <%= node[:sshd][:x11_forwarding] %>
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
PermitUserEnvironment <%= node[:sshd][:permit_user_environment] %>
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none
# no default banner path
Banner <%= node[:sshd][:banner] %>
# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment