blob: d7fb88a5c61e951ce731d7ae12381b1428d14e58 [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
239
240
Dmitry Teselkina6194b52018-08-24 10:56:36 +0300241* OpenSSH server configuration supports AllowUsers, DenyUsers, AllowGroup,
242DenyGroups via allow_users, deny_users, allow_groups, deny_groups keys respectively.
243
244For example, here is how to manage AllowUsers configuration item:
245
246 .. code-block:: yaml
247
248 openssh:
249 server:
250 allow_users:
251 <user_name>:
252 enabled: true
253 <pattern_list_name>:
254 enabled: true
255 pattern: <pattern>
256
257Elements of allow_users are either user names or pattern list names:
258* <user name> goes to configurational file as is.
259* <pattern list name> is not used directly - its main purpose is to provide a
260 meaningfull name for a pattern specified in 'pattern' key. Another advantage
261 is that pattern can be overriden.
262
263<enabled> by default is 'true'.
264
265See PATTERNS in ssh_config(5) for more information on what <pattern> is.
266
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300267**CIS Compliance**
Dmitry Teselkine9420e72018-04-03 13:49:39 +0300268
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300269There is a number of configuration options that make the OpenSSH service
270compliant with CIS Benchmark. These options can be found under
271``metadata/service/server/cis``, and are not enabled by default. For each CIS
272item a comprehensive description is provided with the pillar data.
Dmitry Teselkine9420e72018-04-03 13:49:39 +0300273
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300274See also https://www.cisecurity.org/cis-benchmarks/ for the details abouth
275CIS Benchmark.
Dmitry Teselkine9420e72018-04-03 13:49:39 +0300276
OlgaGusarenko8155e1a2018-06-19 15:35:42 +0300277**Read more**
Filip Pytlouna6d4a782015-10-06 16:28:32 +0200278
279* http://www.openssh.org/manual.html
280* https://help.ubuntu.com/community/SSH/OpenSSH/Configuring
281* http://www.cyberciti.biz/tips/linux-unix-bsd-openssh-server-best-practices.html
282* http://www.zeitoun.net/articles/ssh-through-http-proxy/start