OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 1 | ===== |
| 2 | Usage |
| 3 | ===== |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 4 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 5 | OpenSSH is a free version of the SSH connectivity tools that technical users |
| 6 | of the Internet rely on. The passwords of Telnet, remote login (rlogin), and |
| 7 | File Transfer Protocol (FTP) users are transmitted across the Internet |
| 8 | unencrypted. OpenSSH encrypts all traffic, including passwords, to effectively |
| 9 | eliminate eavesdropping, connection hijacking, and other attacks. Additionally, |
| 10 | OpenSSH provides secure tunneling capabilities and several authentication |
| 11 | methods, and supports all SSH protocol versions. |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 12 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 13 | This file provides the sample pillars configurations for different use cases. |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 14 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 15 | **OpenSSH client** |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 16 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 17 | * The OpenSSH client configuration with a shared private key: |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 18 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 19 | .. code-block:: yaml |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 20 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 21 | 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 Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 32 | |
Dzmitry Stremkouski | 48a25a6 | 2020-03-15 16:52:25 +0100 | [diff] [blame] | 33 | * 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 Stremkouski | 274d983 | 2020-05-24 20:14:12 +0200 | [diff] [blame] | 42 | * 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 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 61 | * The OpenSSH client configuration with an individual private key and known |
| 62 | host: |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 63 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 64 | .. code-block:: yaml |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 65 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 66 | 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 Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 78 | |
Martin Polreich | 186b01f | 2019-08-19 08:29:27 +0200 | [diff] [blame] | 79 | * The OpenSSH client configuration with definition of known_hosts using |
| 80 | public 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 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 104 | * The OpenSSH client configuration with keep alive settings: |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 105 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 106 | .. code-block:: yaml |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 107 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 108 | openssh: |
| 109 | client: |
| 110 | alive: |
| 111 | interval: 600 |
| 112 | count: 3 |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 113 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 114 | **OpenSSH server** |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 115 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 116 | * The OpenSSH server simple configuration: |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 117 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 118 | .. code-block:: yaml |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 119 | |
| 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 Konecny | 2a27423 | 2016-02-16 15:49:35 +0100 | [diff] [blame] | 128 | bind: |
| 129 | address: 0.0.0.0 |
Jiri Konecny | df55053 | 2016-02-17 11:48:47 +0100 | [diff] [blame] | 130 | port: 22 |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 131 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 132 | * The OpenSSH server configuration with auth keys for users: |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 133 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 134 | .. code-block:: yaml |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 135 | |
| 136 | openssh: |
| 137 | server: |
| 138 | enabled: true |
Jiri Konecny | 2a27423 | 2016-02-16 15:49:35 +0100 | [diff] [blame] | 139 | bind: |
| 140 | address: 0.0.0.0 |
Jiri Konecny | df55053 | 2016-02-17 11:48:47 +0100 | [diff] [blame] | 141 | port: 22 |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 142 | ... |
| 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 Pytloun | 2d3c803 | 2016-03-11 16:40:20 +0100 | [diff] [blame] | 151 | purge: true |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 152 | user: ${linux:system:user:root} |
| 153 | public_keys: |
| 154 | - ${public_keys:newt} |
| 155 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 156 | .. 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 Pytloun | a12db4a | 2016-12-02 13:21:02 +0100 | [diff] [blame] | 159 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 160 | * The OpenSSH server configuration that binds OpenSSH on multiple addresses |
| 161 | and ports: |
| 162 | |
| 163 | .. code-block:: yaml |
Filip Pytloun | a12db4a | 2016-12-02 13:21:02 +0100 | [diff] [blame] | 164 | |
| 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 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 174 | * The OpenSSH server with FreeIPA configuration: |
Filip Pytloun | daf8f98 | 2015-12-16 11:55:34 +0100 | [diff] [blame] | 175 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 176 | .. code-block:: yaml |
Filip Pytloun | daf8f98 | 2015-12-16 11:55:34 +0100 | [diff] [blame] | 177 | |
| 178 | openssh: |
| 179 | server: |
| 180 | enabled: true |
Jiri Konecny | 2a27423 | 2016-02-16 15:49:35 +0100 | [diff] [blame] | 181 | bind: |
| 182 | address: 0.0.0.0 |
Jiri Konecny | df55053 | 2016-02-17 11:48:47 +0100 | [diff] [blame] | 183 | port: 22 |
Filip Pytloun | daf8f98 | 2015-12-16 11:55:34 +0100 | [diff] [blame] | 184 | public_key_auth: true |
| 185 | authorized_keys_command: |
| 186 | command: /usr/bin/sss_ssh_authorizedkeys |
| 187 | user: nobody |
| 188 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 189 | * The OpenSSH server configuration with keep alive settings: |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 190 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 191 | .. code-block:: yaml |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 192 | |
| 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 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 202 | * The OpenSSH server configuration with the DSA legacy keys enabled: |
Marek Celoud | 7f50705 | 2017-11-06 15:50:23 +0100 | [diff] [blame] | 203 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 204 | .. code-block:: yaml |
Marek Celoud | 7f50705 | 2017-11-06 15:50:23 +0100 | [diff] [blame] | 205 | |
| 206 | openssh: |
| 207 | server: |
| 208 | dss_enabled: true |
| 209 | |
Gleb Galkin | f6be3cf | 2018-10-17 17:39:24 +0300 | [diff] [blame] | 210 | * The OpenSSH server configuration with the duo 2FA |
| 211 | https://duo.com/docs/duounix |
| 212 | with 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 Zhdanov | 85c7306 | 2020-05-14 19:27:38 +0200 | [diff] [blame] | 239 | * The OpenSSH server configuration with the Key Exchange algorithms list: |
Gleb Galkin | f6be3cf | 2018-10-17 17:39:24 +0300 | [diff] [blame] | 240 | |
Kirill Zhdanov | 85c7306 | 2020-05-14 19:27:38 +0200 | [diff] [blame] | 241 | .. code-block:: yaml |
| 242 | |
| 243 | openssh: |
| 244 | server: |
| 245 | kexalgorithms: |
| 246 | curve25519-sha256: |
| 247 | enabled: true |
| 248 | ecdh-sha2-nistp384: |
| 249 | enabled: true |
| 250 | |
| 251 | The 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 Galkin | f6be3cf | 2018-10-17 17:39:24 +0300 | [diff] [blame] | 262 | |
Dmitry Teselkin | a6194b5 | 2018-08-24 10:56:36 +0300 | [diff] [blame] | 263 | * OpenSSH server configuration supports AllowUsers, DenyUsers, AllowGroup, |
| 264 | DenyGroups via allow_users, deny_users, allow_groups, deny_groups keys respectively. |
| 265 | |
| 266 | For 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 | |
| 279 | Elements 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 | |
| 287 | See PATTERNS in ssh_config(5) for more information on what <pattern> is. |
| 288 | |
Roman Lubianyi | 0ea6e23 | 2020-08-27 18:33:03 +0300 | [diff] [blame^] | 289 | * 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 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 300 | **CIS Compliance** |
Dmitry Teselkin | e9420e7 | 2018-04-03 13:49:39 +0300 | [diff] [blame] | 301 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 302 | There is a number of configuration options that make the OpenSSH service |
| 303 | compliant with CIS Benchmark. These options can be found under |
| 304 | ``metadata/service/server/cis``, and are not enabled by default. For each CIS |
| 305 | item a comprehensive description is provided with the pillar data. |
Dmitry Teselkin | e9420e7 | 2018-04-03 13:49:39 +0300 | [diff] [blame] | 306 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 307 | See also https://www.cisecurity.org/cis-benchmarks/ for the details abouth |
| 308 | CIS Benchmark. |
Dmitry Teselkin | e9420e7 | 2018-04-03 13:49:39 +0300 | [diff] [blame] | 309 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 310 | **Read more** |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 311 | |
| 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 |