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 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 42 | * The OpenSSH client configuration with an individual private key and known |
| 43 | host: |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 44 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 45 | .. code-block:: yaml |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 46 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 47 | 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 Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 59 | |
Martin Polreich | 186b01f | 2019-08-19 08:29:27 +0200 | [diff] [blame] | 60 | * The OpenSSH client configuration with definition of known_hosts using |
| 61 | public 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 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 85 | * The OpenSSH client configuration with keep alive settings: |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 86 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 87 | .. code-block:: yaml |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 88 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 89 | openssh: |
| 90 | client: |
| 91 | alive: |
| 92 | interval: 600 |
| 93 | count: 3 |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 94 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 95 | **OpenSSH server** |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 96 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 97 | * The OpenSSH server simple configuration: |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 98 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 99 | .. code-block:: yaml |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 100 | |
| 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 Konecny | 2a27423 | 2016-02-16 15:49:35 +0100 | [diff] [blame] | 109 | bind: |
| 110 | address: 0.0.0.0 |
Jiri Konecny | df55053 | 2016-02-17 11:48:47 +0100 | [diff] [blame] | 111 | port: 22 |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 112 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 113 | * The OpenSSH server configuration with auth keys for users: |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 114 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 115 | .. code-block:: yaml |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 116 | |
| 117 | openssh: |
| 118 | server: |
| 119 | enabled: true |
Jiri Konecny | 2a27423 | 2016-02-16 15:49:35 +0100 | [diff] [blame] | 120 | bind: |
| 121 | address: 0.0.0.0 |
Jiri Konecny | df55053 | 2016-02-17 11:48:47 +0100 | [diff] [blame] | 122 | port: 22 |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 123 | ... |
| 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 Pytloun | 2d3c803 | 2016-03-11 16:40:20 +0100 | [diff] [blame] | 132 | purge: true |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 133 | user: ${linux:system:user:root} |
| 134 | public_keys: |
| 135 | - ${public_keys:newt} |
| 136 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 137 | .. 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 Pytloun | a12db4a | 2016-12-02 13:21:02 +0100 | [diff] [blame] | 140 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 141 | * The OpenSSH server configuration that binds OpenSSH on multiple addresses |
| 142 | and ports: |
| 143 | |
| 144 | .. code-block:: yaml |
Filip Pytloun | a12db4a | 2016-12-02 13:21:02 +0100 | [diff] [blame] | 145 | |
| 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 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 155 | * The OpenSSH server with FreeIPA configuration: |
Filip Pytloun | daf8f98 | 2015-12-16 11:55:34 +0100 | [diff] [blame] | 156 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 157 | .. code-block:: yaml |
Filip Pytloun | daf8f98 | 2015-12-16 11:55:34 +0100 | [diff] [blame] | 158 | |
| 159 | openssh: |
| 160 | server: |
| 161 | enabled: true |
Jiri Konecny | 2a27423 | 2016-02-16 15:49:35 +0100 | [diff] [blame] | 162 | bind: |
| 163 | address: 0.0.0.0 |
Jiri Konecny | df55053 | 2016-02-17 11:48:47 +0100 | [diff] [blame] | 164 | port: 22 |
Filip Pytloun | daf8f98 | 2015-12-16 11:55:34 +0100 | [diff] [blame] | 165 | public_key_auth: true |
| 166 | authorized_keys_command: |
| 167 | command: /usr/bin/sss_ssh_authorizedkeys |
| 168 | user: nobody |
| 169 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 170 | * The OpenSSH server configuration with keep alive settings: |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 171 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 172 | .. code-block:: yaml |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 173 | |
| 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 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 183 | * The OpenSSH server configuration with the DSA legacy keys enabled: |
Marek Celoud | 7f50705 | 2017-11-06 15:50:23 +0100 | [diff] [blame] | 184 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 185 | .. code-block:: yaml |
Marek Celoud | 7f50705 | 2017-11-06 15:50:23 +0100 | [diff] [blame] | 186 | |
| 187 | openssh: |
| 188 | server: |
| 189 | dss_enabled: true |
| 190 | |
Gleb Galkin | f6be3cf | 2018-10-17 17:39:24 +0300 | [diff] [blame] | 191 | * The OpenSSH server configuration with the duo 2FA |
| 192 | https://duo.com/docs/duounix |
| 193 | with 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 Teselkin | a6194b5 | 2018-08-24 10:56:36 +0300 | [diff] [blame] | 222 | * OpenSSH server configuration supports AllowUsers, DenyUsers, AllowGroup, |
| 223 | DenyGroups via allow_users, deny_users, allow_groups, deny_groups keys respectively. |
| 224 | |
| 225 | For 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 | |
| 238 | Elements 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 | |
| 246 | See PATTERNS in ssh_config(5) for more information on what <pattern> is. |
| 247 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 248 | **CIS Compliance** |
Dmitry Teselkin | e9420e7 | 2018-04-03 13:49:39 +0300 | [diff] [blame] | 249 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 250 | There is a number of configuration options that make the OpenSSH service |
| 251 | compliant with CIS Benchmark. These options can be found under |
| 252 | ``metadata/service/server/cis``, and are not enabled by default. For each CIS |
| 253 | item a comprehensive description is provided with the pillar data. |
Dmitry Teselkin | e9420e7 | 2018-04-03 13:49:39 +0300 | [diff] [blame] | 254 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 255 | See also https://www.cisecurity.org/cis-benchmarks/ for the details abouth |
| 256 | CIS Benchmark. |
Dmitry Teselkin | e9420e7 | 2018-04-03 13:49:39 +0300 | [diff] [blame] | 257 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 258 | **Read more** |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 259 | |
| 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 |