blob: 729f88336e8684d5bf952bbac75b11e835180aac [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
Dzmitry Stremkouski274d9832020-05-24 20:14:12 +020042* The OpenSSH client .ssh/config manipulation:
43
44 .. code-block:: yaml
45
46 openssh:
47 client:
48 enabled: True
49 user:
50 root:
51 enabled: True
52 user:
53 enabled: True
54 name: root
55 home: /root
56 config:
57 git.example.com:
58 username: git
59 identityfile: /root/.ssh/github/id_rsa.key
60
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030061* The OpenSSH client configuration with an individual private key and known
62 host:
Filip Pytlouna6d4a782015-10-06 16:28:32 +020063
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030064 .. code-block:: yaml
Filip Pytlouna6d4a782015-10-06 16:28:32 +020065
OlgaGusarenko8155e1a2018-06-19 15:35:42 +030066 openssh:
67 client:
68 enabled: true
69 user:
70 root:
71 enabled: true
72 user: ${linux:system:user:root}
73 known_hosts:
74 - name: repo.domain.com
75 type: rsa
76 fingerprint: dd:fa:e8:68:b1:ea:ea:a0:63:f1:5a:55:48:e1:7e:37
77 fingerprint_hash_type: sha256|md5
Filip Pytlouna6d4a782015-10-06 16:28:32 +020078
Martin Polreich186b01f2019-08-19 08:29:27 +020079* The OpenSSH client configuration with definition of known_hosts using
80public key instead of fingerprint
81
82 - If `purge_defined` is set to `true` it will remove old known_hosts file
83 and start with a fresh one causing that known_host undefined in the pillar
84 will not be included.
85
86 .. code-block:: yaml
87
88 openssh:
89 client:
90 enabled: true
91 user:
92 root:
93 enabled: true
94 purge_undefined: false
95 user:
96 name: 'root'
97 home: '/root'
98 known_hosts:
99 - name: 10.11.1.50
100 port: 22
101 type: ssh-rsa
102 host_public_key: AAA...fkP
103
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300104* The OpenSSH client configuration with keep alive settings:
Petr Michalec244a6422017-08-10 09:43:53 +0200105
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300106 .. code-block:: yaml
Petr Michalec244a6422017-08-10 09:43:53 +0200107
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300108 openssh:
109 client:
110 alive:
111 interval: 600
112 count: 3
Petr Michalec244a6422017-08-10 09:43:53 +0200113
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300114**OpenSSH server**
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200115
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300116* The OpenSSH server simple configuration:
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200117
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300118 .. code-block:: yaml
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200119
120 openssh:
121 server:
122 enabled: true
123 permit_root_login: true
124 public_key_auth: true
125 password_auth: true
126 host_auth: true
127 banner: Welcome to server!
Jiri Konecny2a274232016-02-16 15:49:35 +0100128 bind:
129 address: 0.0.0.0
Jiri Konecnydf550532016-02-17 11:48:47 +0100130 port: 22
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200131
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300132* The OpenSSH server configuration with auth keys for users:
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200133
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300134 .. code-block:: yaml
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200135
136 openssh:
137 server:
138 enabled: true
Jiri Konecny2a274232016-02-16 15:49:35 +0100139 bind:
140 address: 0.0.0.0
Jiri Konecnydf550532016-02-17 11:48:47 +0100141 port: 22
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200142 ...
143 user:
144 newt:
145 enabled: true
146 user: ${linux:system:user:newt}
147 public_keys:
148 - ${public_keys:newt}
149 root:
150 enabled: true
Filip Pytloun2d3c8032016-03-11 16:40:20 +0100151 purge: true
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200152 user: ${linux:system:user:root}
153 public_keys:
154 - ${public_keys:newt}
155
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300156 .. note:: Setting the ``purge`` parameter to ``true`` ensures that the exact
157 ``authorized_keys`` contents will be filled explicitly from the model and
158 undefined keys will be removed.
Filip Pytlouna12db4a2016-12-02 13:21:02 +0100159
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300160* The OpenSSH server configuration that binds OpenSSH on multiple addresses
161 and ports:
162
163 .. code-block:: yaml
Filip Pytlouna12db4a2016-12-02 13:21:02 +0100164
165 openssh:
166 server:
167 enabled: true
168 binds:
169 - address: 127.0.0.1
170 port: 22
171 - address: 192.168.1.1
172 port: 2222
173
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300174* The OpenSSH server with FreeIPA configuration:
Filip Pytloundaf8f982015-12-16 11:55:34 +0100175
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300176 .. code-block:: yaml
Filip Pytloundaf8f982015-12-16 11:55:34 +0100177
178 openssh:
179 server:
180 enabled: true
Jiri Konecny2a274232016-02-16 15:49:35 +0100181 bind:
182 address: 0.0.0.0
Jiri Konecnydf550532016-02-17 11:48:47 +0100183 port: 22
Filip Pytloundaf8f982015-12-16 11:55:34 +0100184 public_key_auth: true
185 authorized_keys_command:
186 command: /usr/bin/sss_ssh_authorizedkeys
187 user: nobody
188
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300189* The OpenSSH server configuration with keep alive settings:
Petr Michalec244a6422017-08-10 09:43:53 +0200190
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300191 .. code-block:: yaml
Petr Michalec244a6422017-08-10 09:43:53 +0200192
193 openssh:
194 server:
195 alive:
196 keep: yes
197 interval: 600
198 count: 3
199 #
200 # will give you an timeout of 30 minutes (600 sec x 3)
201
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300202* The OpenSSH server configuration with the DSA legacy keys enabled:
Marek Celoud7f507052017-11-06 15:50:23 +0100203
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300204 .. code-block:: yaml
Marek Celoud7f507052017-11-06 15:50:23 +0100205
206 openssh:
207 server:
208 dss_enabled: true
209
Gleb Galkinf6be3cf2018-10-17 17:39:24 +0300210* The OpenSSH server configuration with the duo 2FA
211https://duo.com/docs/duounix
212with Match User 2FA can be bypassed for some accounts
213
214 .. code-block:: yaml
215
216 openssh:
217 server:
218 use_dns: false
219 password_auth: false
220 challenge_response_auth: true
221 ciphers:
222 aes256-ctr:
223 enabled: true
224 aes192-ctr:
225 enabled: true
226 aes128-ctr:
227 enabled: true
228 authentication_methods:
229 publickey:
230 enabled: true
231 keyboard-interactive:
232 enabled: true
233 match_user:
234 jenkins:
235 authentication_methods:
236 publickey:
237 enabled: true
238
Kirill Zhdanov85c73062020-05-14 19:27:38 +0200239* The OpenSSH server configuration with the Key Exchange algorithms list:
Gleb Galkinf6be3cf2018-10-17 17:39:24 +0300240
Kirill Zhdanov85c73062020-05-14 19:27:38 +0200241 .. code-block:: yaml
242
243 openssh:
244 server:
245 kexalgorithms:
246 curve25519-sha256:
247 enabled: true
248 ecdh-sha2-nistp384:
249 enabled: true
250
251The OpenSSH server configuration with the Host Key algorithms list:
252
253 .. code-block:: yaml
254
255 openssh:
256 server:
257 hostkeyalgorithms:
258 rsa-sha2-256:
259 enabled: true
260 ecdsa-sha2-nistp256:
261 enabled: true
Gleb Galkinf6be3cf2018-10-17 17:39:24 +0300262
Dmitry Teselkina6194b52018-08-24 10:56:36 +0300263* OpenSSH server configuration supports AllowUsers, DenyUsers, AllowGroup,
264DenyGroups via allow_users, deny_users, allow_groups, deny_groups keys respectively.
265
266For example, here is how to manage AllowUsers configuration item:
267
268 .. code-block:: yaml
269
270 openssh:
271 server:
272 allow_users:
273 <user_name>:
274 enabled: true
275 <pattern_list_name>:
276 enabled: true
277 pattern: <pattern>
278
279Elements of allow_users are either user names or pattern list names:
280* <user name> goes to configurational file as is.
281* <pattern list name> is not used directly - its main purpose is to provide a
282 meaningfull name for a pattern specified in 'pattern' key. Another advantage
283 is that pattern can be overriden.
284
285<enabled> by default is 'true'.
286
287See PATTERNS in ssh_config(5) for more information on what <pattern> is.
288
Roman Lubianyi0ea6e232020-08-27 18:33:03 +0300289* Use ECDSA key format for the OpenSSH client known_hosts file:
290
291 - If `known_hosts_use_ecdsa` is set to `true` it will use ECDSA key format
292 in known_hosts otherwise RSA key format wil be used
293
294 .. code-block:: yaml
295
296 openssh:
297 client:
298 known_hosts_use_ecdsa: true
299
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300300**CIS Compliance**
Dmitry Teselkine9420e72018-04-03 13:49:39 +0300301
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300302There is a number of configuration options that make the OpenSSH service
303compliant with CIS Benchmark. These options can be found under
304``metadata/service/server/cis``, and are not enabled by default. For each CIS
305item a comprehensive description is provided with the pillar data.
Dmitry Teselkine9420e72018-04-03 13:49:39 +0300306
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300307See also https://www.cisecurity.org/cis-benchmarks/ for the details abouth
308CIS Benchmark.
Dmitry Teselkine9420e72018-04-03 13:49:39 +0300309
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300310**Read more**
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200311
312* http://www.openssh.org/manual.html
313* https://help.ubuntu.com/community/SSH/OpenSSH/Configuring
314* http://www.cyberciti.biz/tips/linux-unix-bsd-openssh-server-best-practices.html
315* http://www.zeitoun.net/articles/ssh-through-http-proxy/start