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 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 33 | * The OpenSSH client configuration with an individual private key and known |
| 34 | host: |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 35 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 36 | .. code-block:: yaml |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 37 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 38 | openssh: |
| 39 | client: |
| 40 | enabled: true |
| 41 | user: |
| 42 | root: |
| 43 | enabled: true |
| 44 | user: ${linux:system:user:root} |
| 45 | known_hosts: |
| 46 | - name: repo.domain.com |
| 47 | type: rsa |
| 48 | fingerprint: dd:fa:e8:68:b1:ea:ea:a0:63:f1:5a:55:48:e1:7e:37 |
| 49 | fingerprint_hash_type: sha256|md5 |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 50 | |
Martin Polreich | 186b01f | 2019-08-19 08:29:27 +0200 | [diff] [blame] | 51 | * The OpenSSH client configuration with definition of known_hosts using |
| 52 | public key instead of fingerprint |
| 53 | |
| 54 | - If `purge_defined` is set to `true` it will remove old known_hosts file |
| 55 | and start with a fresh one causing that known_host undefined in the pillar |
| 56 | will not be included. |
| 57 | |
| 58 | .. code-block:: yaml |
| 59 | |
| 60 | openssh: |
| 61 | client: |
| 62 | enabled: true |
| 63 | user: |
| 64 | root: |
| 65 | enabled: true |
| 66 | purge_undefined: false |
| 67 | user: |
| 68 | name: 'root' |
| 69 | home: '/root' |
| 70 | known_hosts: |
| 71 | - name: 10.11.1.50 |
| 72 | port: 22 |
| 73 | type: ssh-rsa |
| 74 | host_public_key: AAA...fkP |
| 75 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 76 | * The OpenSSH client configuration with keep alive settings: |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 77 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 78 | .. code-block:: yaml |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 79 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 80 | openssh: |
| 81 | client: |
| 82 | alive: |
| 83 | interval: 600 |
| 84 | count: 3 |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 85 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 86 | **OpenSSH server** |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 87 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 88 | * The OpenSSH server simple configuration: |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 89 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 90 | .. code-block:: yaml |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 91 | |
| 92 | openssh: |
| 93 | server: |
| 94 | enabled: true |
| 95 | permit_root_login: true |
| 96 | public_key_auth: true |
| 97 | password_auth: true |
| 98 | host_auth: true |
| 99 | banner: Welcome to server! |
Jiri Konecny | 2a27423 | 2016-02-16 15:49:35 +0100 | [diff] [blame] | 100 | bind: |
| 101 | address: 0.0.0.0 |
Jiri Konecny | df55053 | 2016-02-17 11:48:47 +0100 | [diff] [blame] | 102 | port: 22 |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 103 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 104 | * The OpenSSH server configuration with auth keys for users: |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 105 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 106 | .. code-block:: yaml |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 107 | |
| 108 | openssh: |
| 109 | server: |
| 110 | enabled: true |
Jiri Konecny | 2a27423 | 2016-02-16 15:49:35 +0100 | [diff] [blame] | 111 | bind: |
| 112 | address: 0.0.0.0 |
Jiri Konecny | df55053 | 2016-02-17 11:48:47 +0100 | [diff] [blame] | 113 | port: 22 |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 114 | ... |
| 115 | user: |
| 116 | newt: |
| 117 | enabled: true |
| 118 | user: ${linux:system:user:newt} |
| 119 | public_keys: |
| 120 | - ${public_keys:newt} |
| 121 | root: |
| 122 | enabled: true |
Filip Pytloun | 2d3c803 | 2016-03-11 16:40:20 +0100 | [diff] [blame] | 123 | purge: true |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 124 | user: ${linux:system:user:root} |
| 125 | public_keys: |
| 126 | - ${public_keys:newt} |
| 127 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 128 | .. note:: Setting the ``purge`` parameter to ``true`` ensures that the exact |
| 129 | ``authorized_keys`` contents will be filled explicitly from the model and |
| 130 | undefined keys will be removed. |
Filip Pytloun | a12db4a | 2016-12-02 13:21:02 +0100 | [diff] [blame] | 131 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 132 | * The OpenSSH server configuration that binds OpenSSH on multiple addresses |
| 133 | and ports: |
| 134 | |
| 135 | .. code-block:: yaml |
Filip Pytloun | a12db4a | 2016-12-02 13:21:02 +0100 | [diff] [blame] | 136 | |
| 137 | openssh: |
| 138 | server: |
| 139 | enabled: true |
| 140 | binds: |
| 141 | - address: 127.0.0.1 |
| 142 | port: 22 |
| 143 | - address: 192.168.1.1 |
| 144 | port: 2222 |
| 145 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 146 | * The OpenSSH server with FreeIPA configuration: |
Filip Pytloun | daf8f98 | 2015-12-16 11:55:34 +0100 | [diff] [blame] | 147 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 148 | .. code-block:: yaml |
Filip Pytloun | daf8f98 | 2015-12-16 11:55:34 +0100 | [diff] [blame] | 149 | |
| 150 | openssh: |
| 151 | server: |
| 152 | enabled: true |
Jiri Konecny | 2a27423 | 2016-02-16 15:49:35 +0100 | [diff] [blame] | 153 | bind: |
| 154 | address: 0.0.0.0 |
Jiri Konecny | df55053 | 2016-02-17 11:48:47 +0100 | [diff] [blame] | 155 | port: 22 |
Filip Pytloun | daf8f98 | 2015-12-16 11:55:34 +0100 | [diff] [blame] | 156 | public_key_auth: true |
| 157 | authorized_keys_command: |
| 158 | command: /usr/bin/sss_ssh_authorizedkeys |
| 159 | user: nobody |
| 160 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 161 | * The OpenSSH server configuration with keep alive settings: |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 162 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 163 | .. code-block:: yaml |
Petr Michalec | 244a642 | 2017-08-10 09:43:53 +0200 | [diff] [blame] | 164 | |
| 165 | openssh: |
| 166 | server: |
| 167 | alive: |
| 168 | keep: yes |
| 169 | interval: 600 |
| 170 | count: 3 |
| 171 | # |
| 172 | # will give you an timeout of 30 minutes (600 sec x 3) |
| 173 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 174 | * The OpenSSH server configuration with the DSA legacy keys enabled: |
Marek Celoud | 7f50705 | 2017-11-06 15:50:23 +0100 | [diff] [blame] | 175 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 176 | .. code-block:: yaml |
Marek Celoud | 7f50705 | 2017-11-06 15:50:23 +0100 | [diff] [blame] | 177 | |
| 178 | openssh: |
| 179 | server: |
| 180 | dss_enabled: true |
| 181 | |
Gleb Galkin | f6be3cf | 2018-10-17 17:39:24 +0300 | [diff] [blame] | 182 | * The OpenSSH server configuration with the duo 2FA |
| 183 | https://duo.com/docs/duounix |
| 184 | with Match User 2FA can be bypassed for some accounts |
| 185 | |
| 186 | .. code-block:: yaml |
| 187 | |
| 188 | openssh: |
| 189 | server: |
| 190 | use_dns: false |
| 191 | password_auth: false |
| 192 | challenge_response_auth: true |
| 193 | ciphers: |
| 194 | aes256-ctr: |
| 195 | enabled: true |
| 196 | aes192-ctr: |
| 197 | enabled: true |
| 198 | aes128-ctr: |
| 199 | enabled: true |
| 200 | authentication_methods: |
| 201 | publickey: |
| 202 | enabled: true |
| 203 | keyboard-interactive: |
| 204 | enabled: true |
| 205 | match_user: |
| 206 | jenkins: |
| 207 | authentication_methods: |
| 208 | publickey: |
| 209 | enabled: true |
| 210 | |
| 211 | |
| 212 | |
Dmitry Teselkin | a6194b5 | 2018-08-24 10:56:36 +0300 | [diff] [blame] | 213 | * OpenSSH server configuration supports AllowUsers, DenyUsers, AllowGroup, |
| 214 | DenyGroups via allow_users, deny_users, allow_groups, deny_groups keys respectively. |
| 215 | |
| 216 | For example, here is how to manage AllowUsers configuration item: |
| 217 | |
| 218 | .. code-block:: yaml |
| 219 | |
| 220 | openssh: |
| 221 | server: |
| 222 | allow_users: |
| 223 | <user_name>: |
| 224 | enabled: true |
| 225 | <pattern_list_name>: |
| 226 | enabled: true |
| 227 | pattern: <pattern> |
| 228 | |
| 229 | Elements of allow_users are either user names or pattern list names: |
| 230 | * <user name> goes to configurational file as is. |
| 231 | * <pattern list name> is not used directly - its main purpose is to provide a |
| 232 | meaningfull name for a pattern specified in 'pattern' key. Another advantage |
| 233 | is that pattern can be overriden. |
| 234 | |
| 235 | <enabled> by default is 'true'. |
| 236 | |
| 237 | See PATTERNS in ssh_config(5) for more information on what <pattern> is. |
| 238 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 239 | **CIS Compliance** |
Dmitry Teselkin | e9420e7 | 2018-04-03 13:49:39 +0300 | [diff] [blame] | 240 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 241 | There is a number of configuration options that make the OpenSSH service |
| 242 | compliant with CIS Benchmark. These options can be found under |
| 243 | ``metadata/service/server/cis``, and are not enabled by default. For each CIS |
| 244 | item a comprehensive description is provided with the pillar data. |
Dmitry Teselkin | e9420e7 | 2018-04-03 13:49:39 +0300 | [diff] [blame] | 245 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 246 | See also https://www.cisecurity.org/cis-benchmarks/ for the details abouth |
| 247 | CIS Benchmark. |
Dmitry Teselkin | e9420e7 | 2018-04-03 13:49:39 +0300 | [diff] [blame] | 248 | |
OlgaGusarenko | 8155e1a | 2018-06-19 15:35:42 +0300 | [diff] [blame] | 249 | **Read more** |
Filip Pytloun | a6d4a78 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 250 | |
| 251 | * http://www.openssh.org/manual.html |
| 252 | * https://help.ubuntu.com/community/SSH/OpenSSH/Configuring |
| 253 | * http://www.cyberciti.biz/tips/linux-unix-bsd-openssh-server-best-practices.html |
| 254 | * http://www.zeitoun.net/articles/ssh-through-http-proxy/start |