sshd_config.erb 3.92 KB
Newer Older
Adam Lewenberg's avatar
Adam Lewenberg committed
1 2 3 4 5 6
# sshd server configuration file, allowing root.  -*- conf -*-
#
# This sshd configuration permits root logins provided that they're done via
# GSS-API.  It will eventually become the default.  The default configuration
# values that we don't change are omitted from this file.

7 8 9 10 11 12
<%-
  # Split the ports at the commas.
  ports = @listen_ports.split(',')
  ports.each do |port|
-%>
Port <%= port %>
13
<%-
14 15 16
  end
-%>

17
<%-
18
  if (@listen_addresses != 'all')
19
    # Split the addresses at the commas.
20
    addresses = @listen_addresses.split(',')
21 22 23
    addresses.each do |address|
-%>
ListenAddress <%= address %>
24
<%-
25 26
    end
-%>
27

28 29 30
<%-
  end
-%>
31
# Only support protocol version 2.
Adam Lewenberg's avatar
Adam Lewenberg committed
32 33 34 35 36
Protocol 2

# Only support RSA keys, not DSA keys.
HostKey /etc/ssh/ssh_host_rsa_key

Adam Lewenberg's avatar
Adam Lewenberg committed
37
<% if @ed25519 then -%>
38 39 40 41
# Also support Ed25519 host keys.
HostKey /etc/ssh/ssh_host_ed25519_key

<% end -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
42 43 44 45
# Increase the login grace period from 120 seconds to 300 seconds (5 minutes).
LoginGraceTime 300

# Prevent attackers from running long password guessing attacks.
46
MaxAuthTries <%= @max_tries %>
Adam Lewenberg's avatar
Adam Lewenberg committed
47

48
<% if @osfamily == 'RedHat' then -%>
49 50 51 52
# Some Red Hat systems are old enough that this has to be explicitly enabled.
UsePrivilegeSeparation yes

<% end -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
53 54 55 56
# Disable all forms of host-based and public key authentication by default,
# since we use GSS-API (or passwords).
IgnoreRhosts yes
RSAAuthentication no
57
PubkeyAuthentication <%= @pubkey ? 'yes' : 'no' %>
Adam Lewenberg's avatar
Adam Lewenberg committed
58
RhostsRSAAuthentication no
59
HostbasedAuthentication <%= @hostbased ? 'yes' : 'no' %>
Adam Lewenberg's avatar
Adam Lewenberg committed
60 61 62

# Allow password authentication via PAM, but not empty passwords.
ChallengeResponseAuthentication yes
Adam Lewenberg's avatar
Adam Lewenberg committed
63
PasswordAuthentication <%= @password ? 'yes' : 'no' %>
Adam Lewenberg's avatar
Adam Lewenberg committed
64 65 66 67 68 69 70
UsePAM yes
PermitEmptyPasswords no

# Enable GSS-API authentication.  Eventually (squeeze and later) we will want
# to add GSSAPIStoreCredentialsOnRekey yes.
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
Adam Lewenberg's avatar
Adam Lewenberg committed
71
<% if (@osfamily != 'RedHat') or (@lsbmajdistrelease.to_i() >= 6) then -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
72 73 74
GSSAPIKeyExchange yes
GSSAPIStrictAcceptorCheck no
<% end -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
75
<% if (@operatingsystem == 'Debian') and (@lsbdistcodename != 'lenny') then -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
76 77
GSSAPIStoreCredentialsOnRekey yes
<% end -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
78
<% if (@osfamily == 'RedHat') and (@lsbmajdistrelease.to_i() >= 6) then -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
79 80
GSSAPIStoreCredentialsOnRekey yes
<% end -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
81
<% if (@operatingsystem == 'Ubuntu') then -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
82 83
GSSAPIStoreCredentialsOnRekey yes
<% end -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
84
<% if (@pam_duo) then -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
85

Adam Lewenberg's avatar
Adam Lewenberg committed
86
# Require both (GSS-API|PASSWORD) and PAM.
Adam Lewenberg's avatar
Adam Lewenberg committed
87
AuthenticationMethods gssapi-with-mic,keyboard-interactive:pam<% if @password then %> password,keyboard-interactive:pam<% end %>
Adam Lewenberg's avatar
Adam Lewenberg committed
88 89
KerberosAuthentication yes
<% end -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
90

91 92 93 94
<%- if (@rootloginwithpswd == 'yes') -%>
# Allow root login with a password (use with care!)
PermitRootLogin yes
<% else -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
95 96
# Allow root login, but only if no password was used (meaning GSS-API).
PermitRootLogin without-password
97
<% end -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
98 99 100 101 102

# Allow X forwarding.
X11Forwarding yes
X11DisplayOffset 10

103
<% if @osfamily != 'RedHat' then -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
104 105 106
# Disable printing of the MOTD, since this is done via other means on Debian.
PrintMotd no

107
<% end -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
108 109 110 111 112
# Send TCP keep-alive messages to keep the connection open through firewalls
# and notice connection termination.
TCPKeepAlive yes

# Enable sftp.
113
<% if @osfamily == 'RedHat' then -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
114 115 116 117
Subsystem sftp /usr/libexec/openssh/sftp-server
<% else -%>
Subsystem sftp /usr/lib/openssh/sftp-server
<% end -%>
118
<% if @gitolite then -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
119 120 121 122 123

# gitolite user should run through a wrapper to map it to actual user.
Match User gitolite
    ForceCommand /usr/share/gitolite/gitolite-wrapper
<% end -%>
Adam Lewenberg's avatar
Adam Lewenberg committed
124 125 126 127 128 129 130 131 132
<%- if (@max_sessions != 'NOT DEFINED') then -%>

<%-   if (@max_sessions <= 10) then -%>
# Allow fewer sessions
<%-   else -%>
# Allow more sessions
<%-   end -%>
MaxSessions <%= @max_sessions %>
<%- end -%>
133 134 135 136
<% if (@pam_duo) and (@rootloginwithpswd == 'no') then -%>

# Because we are enabling Duo but root logins cannot use Duo (yet),
# we have to configure the authentications for root separately.
137
Match User root,root.*,*.root,admin.*,*.admin
138 139 140
  AuthenticationMethods gssapi-with-mic
  MaxSessions 3
<% end -%>