blob: 9e7a3b15eff1878ec4c414c7e03efd0a241963ef [file] [log] [blame]
OlgaGusarenko8155e1a2018-06-19 15:35:42 +03001=====
2Usage
3=====
Filip Pytlouna6d4a782015-10-06 16:28:32 +02004
OlgaGusarenko8155e1a2018-06-19 15:35:42 +03005OpenSSH is a free version of the SSH connectivity tools that technical users
6of the Internet rely on. The passwords of Telnet, remote login (rlogin), and
7File Transfer Protocol (FTP) users are transmitted across the Internet
8unencrypted. OpenSSH encrypts all traffic, including passwords, to effectively
9eliminate eavesdropping, connection hijacking, and other attacks. Additionally,
10OpenSSH provides secure tunneling capabilities and several authentication
11methods, and supports all SSH protocol versions.
Filip Pytlouna6d4a782015-10-06 16:28:32 +020012
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030013This file provides the sample pillars configurations for different use cases.
Filip Pytlouna6d4a782015-10-06 16:28:32 +020014
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030015**OpenSSH client**
Filip Pytlouna6d4a782015-10-06 16:28:32 +020016
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030017* The OpenSSH client configuration with a shared private key:
Filip Pytlouna6d4a782015-10-06 16:28:32 +020018
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030019 .. code-block:: yaml
Filip Pytlouna6d4a782015-10-06 16:28:32 +020020
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030021 openssh:
22 client:
23 enabled: true
24 use_dns: False
25 user:
26 root:
27 enabled: true
28 private_key:
29 type: rsa
30 key: ${_param:root_private_key}
31 user: ${linux:system:user:root}
Filip Pytlouna6d4a782015-10-06 16:28:32 +020032
Dzmitry Stremkouski48a25a62020-03-15 16:52:25 +010033* The OpenSSH client known_hosts autopopulation control:
34
35 .. code-block:: yaml
36
37 openssh:
38 client:
39 enabled: true
40 known_hosts_autopopulation: false
41
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030042* The OpenSSH client configuration with an individual private key and known
43 host:
Filip Pytlouna6d4a782015-10-06 16:28:32 +020044
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030045 .. code-block:: yaml
Filip Pytlouna6d4a782015-10-06 16:28:32 +020046
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030047 openssh:
48 client:
49 enabled: true
50 user:
51 root:
52 enabled: true
53 user: ${linux:system:user:root}
54 known_hosts:
55 - name: repo.domain.com
56 type: rsa
57 fingerprint: dd:fa:e8:68:b1:ea:ea:a0:63:f1:5a:55:48:e1:7e:37
58 fingerprint_hash_type: sha256|md5
Filip Pytlouna6d4a782015-10-06 16:28:32 +020059
Martin Polreich186b01f2019-08-19 08:29:27 +020060* The OpenSSH client configuration with definition of known_hosts using
61public key instead of fingerprint
62
63 - If `purge_defined` is set to `true` it will remove old known_hosts file
64 and start with a fresh one causing that known_host undefined in the pillar
65 will not be included.
66
67 .. code-block:: yaml
68
69 openssh:
70 client:
71 enabled: true
72 user:
73 root:
74 enabled: true
75 purge_undefined: false
76 user:
77 name: 'root'
78 home: '/root'
79 known_hosts:
80 - name: 10.11.1.50
81 port: 22
82 type: ssh-rsa
83 host_public_key: AAA...fkP
84
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030085* The OpenSSH client configuration with keep alive settings:
Petr Michalec244a6422017-08-10 09:43:53 +020086
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030087 .. code-block:: yaml
Petr Michalec244a6422017-08-10 09:43:53 +020088
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030089 openssh:
90 client:
91 alive:
92 interval: 600
93 count: 3
Petr Michalec244a6422017-08-10 09:43:53 +020094
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030095**OpenSSH server**
Filip Pytlouna6d4a782015-10-06 16:28:32 +020096
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030097* The OpenSSH server simple configuration:
Filip Pytlouna6d4a782015-10-06 16:28:32 +020098
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030099 .. code-block:: yaml
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200100
101 openssh:
102 server:
103 enabled: true
104 permit_root_login: true
105 public_key_auth: true
106 password_auth: true
107 host_auth: true
108 banner: Welcome to server!
Jiri Konecny2a274232016-02-16 15:49:35 +0100109 bind:
110 address: 0.0.0.0
Jiri Konecnydf550532016-02-17 11:48:47 +0100111 port: 22
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200112
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300113* The OpenSSH server configuration with auth keys for users:
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200114
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300115 .. code-block:: yaml
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200116
117 openssh:
118 server:
119 enabled: true
Jiri Konecny2a274232016-02-16 15:49:35 +0100120 bind:
121 address: 0.0.0.0
Jiri Konecnydf550532016-02-17 11:48:47 +0100122 port: 22
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200123 ...
124 user:
125 newt:
126 enabled: true
127 user: ${linux:system:user:newt}
128 public_keys:
129 - ${public_keys:newt}
130 root:
131 enabled: true
Filip Pytloun2d3c8032016-03-11 16:40:20 +0100132 purge: true
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200133 user: ${linux:system:user:root}
134 public_keys:
135 - ${public_keys:newt}
136
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300137 .. note:: Setting the ``purge`` parameter to ``true`` ensures that the exact
138 ``authorized_keys`` contents will be filled explicitly from the model and
139 undefined keys will be removed.
Filip Pytlouna12db4a2016-12-02 13:21:02 +0100140
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300141* The OpenSSH server configuration that binds OpenSSH on multiple addresses
142 and ports:
143
144 .. code-block:: yaml
Filip Pytlouna12db4a2016-12-02 13:21:02 +0100145
146 openssh:
147 server:
148 enabled: true
149 binds:
150 - address: 127.0.0.1
151 port: 22
152 - address: 192.168.1.1
153 port: 2222
154
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300155* The OpenSSH server with FreeIPA configuration:
Filip Pytloundaf8f982015-12-16 11:55:34 +0100156
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300157 .. code-block:: yaml
Filip Pytloundaf8f982015-12-16 11:55:34 +0100158
159 openssh:
160 server:
161 enabled: true
Jiri Konecny2a274232016-02-16 15:49:35 +0100162 bind:
163 address: 0.0.0.0
Jiri Konecnydf550532016-02-17 11:48:47 +0100164 port: 22
Filip Pytloundaf8f982015-12-16 11:55:34 +0100165 public_key_auth: true
166 authorized_keys_command:
167 command: /usr/bin/sss_ssh_authorizedkeys
168 user: nobody
169
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300170* The OpenSSH server configuration with keep alive settings:
Petr Michalec244a6422017-08-10 09:43:53 +0200171
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300172 .. code-block:: yaml
Petr Michalec244a6422017-08-10 09:43:53 +0200173
174 openssh:
175 server:
176 alive:
177 keep: yes
178 interval: 600
179 count: 3
180 #
181 # will give you an timeout of 30 minutes (600 sec x 3)
182
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300183* The OpenSSH server configuration with the DSA legacy keys enabled:
Marek Celoud7f507052017-11-06 15:50:23 +0100184
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300185 .. code-block:: yaml
Marek Celoud7f507052017-11-06 15:50:23 +0100186
187 openssh:
188 server:
189 dss_enabled: true
190
Gleb Galkinf6be3cf2018-10-17 17:39:24 +0300191* The OpenSSH server configuration with the duo 2FA
192https://duo.com/docs/duounix
193with Match User 2FA can be bypassed for some accounts
194
195 .. code-block:: yaml
196
197 openssh:
198 server:
199 use_dns: false
200 password_auth: false
201 challenge_response_auth: true
202 ciphers:
203 aes256-ctr:
204 enabled: true
205 aes192-ctr:
206 enabled: true
207 aes128-ctr:
208 enabled: true
209 authentication_methods:
210 publickey:
211 enabled: true
212 keyboard-interactive:
213 enabled: true
214 match_user:
215 jenkins:
216 authentication_methods:
217 publickey:
218 enabled: true
219
220
221
Dmitry Teselkina6194b52018-08-24 10:56:36 +0300222* OpenSSH server configuration supports AllowUsers, DenyUsers, AllowGroup,
223DenyGroups via allow_users, deny_users, allow_groups, deny_groups keys respectively.
224
225For example, here is how to manage AllowUsers configuration item:
226
227 .. code-block:: yaml
228
229 openssh:
230 server:
231 allow_users:
232 <user_name>:
233 enabled: true
234 <pattern_list_name>:
235 enabled: true
236 pattern: <pattern>
237
238Elements of allow_users are either user names or pattern list names:
239* <user name> goes to configurational file as is.
240* <pattern list name> is not used directly - its main purpose is to provide a
241 meaningfull name for a pattern specified in 'pattern' key. Another advantage
242 is that pattern can be overriden.
243
244<enabled> by default is 'true'.
245
246See PATTERNS in ssh_config(5) for more information on what <pattern> is.
247
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300248**CIS Compliance**
Dmitry Teselkine9420e72018-04-03 13:49:39 +0300249
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300250There is a number of configuration options that make the OpenSSH service
251compliant with CIS Benchmark. These options can be found under
252``metadata/service/server/cis``, and are not enabled by default. For each CIS
253item a comprehensive description is provided with the pillar data.
Dmitry Teselkine9420e72018-04-03 13:49:39 +0300254
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300255See also https://www.cisecurity.org/cis-benchmarks/ for the details abouth
256CIS Benchmark.
Dmitry Teselkine9420e72018-04-03 13:49:39 +0300257
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300258**Read more**
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200259
260* http://www.openssh.org/manual.html
261* https://help.ubuntu.com/community/SSH/OpenSSH/Configuring
262* http://www.cyberciti.biz/tips/linux-unix-bsd-openssh-server-best-practices.html
263* http://www.zeitoun.net/articles/ssh-through-http-proxy/start