@@ -19,93 +19,105 @@ def initialize(puppet_env_info = DEFAULT_PUPPET_ENV_INFO)
1919 @warning_message = <<DOC
2020
2121#{ '#' *72 }
22- Per security policy, SIMP, by default, disables login via `ssh` for all users,
23- including `root`, and beginning with SIMP 6.0.0, disables `root` logins at
24- the console by default. So, if one of the following scenarios applies, you
25- should configure a local user for this server to have both `su` and `ssh`
26- privileges, in order to prevent `root` lockout from the system:
22+ By default, SIMP:
2723
28- * Console access is available but not allowed for `root` and no other
29- administrative user account has yet been created .
24+ * Disables remote logins for all users.
25+ * Disables `root` logins at the console .
3026
31- * This can happen when SIMP is installed from RPM and the user accepts
32- `simp config`'s default value for `useradd:securetty` (an empty array).
27+ If one of the following scenarios applies, you MUST enable `sudo` and `ssh`
28+ access for a local user. If you do not do this, you may lose access to your
29+ system.
3330
34- * Both console access is not available and the administrative user's `ssh`
35- access has not yet been enabled (permanently) via Puppet.
31+ SCENARIO 1:
3632
37- * This can happen when SIMP is installed from RPM on cloud systems.
33+ Console access is available, but not allowed, for `root` and no other user
34+ account is available.
3835
39- If you have access to the console, have the `root` password, and have enabled
40- `root` console access by specifying an appropriate TTY when `simp config`
41- asked you about `useradd::securetty` (e.g., `tty0`), this warning is not
42- applicable. If there are no other issues identified in this file, you can
43- simply remove it and run `simp bootstrap`.
36+ * This generally occurs when SIMP is installed from RPM and the user
37+ accepts `simp config`'s default value for `useradd:securetty`
38+ (an empty array).
4439
45- Otherwise, to address the potential `root` lockout issue, follow the
46- instructions below.
40+ SCENARIO 2:
4741
42+ Console access is not available and the administrative user's `ssh`
43+ access has not yet been enabled permanently via Puppet.
44+
45+ * This generally occurs when SIMP is installed from RPM on cloud systems.
46+
47+ In either of these scenarios, `simp config` will create this lock file which
48+ prevents `simp bootstrap` from progressing.
49+
50+ This remainder of this document provides instructions on creating a local user
51+ that has the appropriate level of system access.
52+
53+ -------------------------------
4854Configure Local User for Access
4955-------------------------------
5056
51- In these instructions, you will create a manifest in a local module, `mymodule`,
52- in the `production` Puppet environment. Execute these operations as `root` .
57+ This example creates a `local_system_access` Puppet module in the `production`
58+ Puppet environment.
5359
54- * See https://puppet.com/docs/puppet/latest/modules.html for information on how
55- to create a Puppet module.
60+ * IF YOU ALREADY HAVE AN UNPRIVILEGED ACCOUNT:
5661
57- 1. Create a local user account, as needed, using `useradd`. This example
58- assumes the local user is `userx` .
62+ * Replace `userx` with your current NON-ROOT username throughout the
63+ example code .
5964
60- * Be sure to set the user's password if the user is logging in with a password.
61- * SIMP is configured to create a home directory for the user, if it does
62- not exist when the user first logs in.
65+ * IF YOU DO not ALREADY HAVE AN UNPRIVILEGED ACCOUNT:
6366
64- 2. Create a `local_user.pp` manifest in `mymodule/manifests` to enable
65- `sudo su - root` and allow `ssh` access for the user you created/selected:
67+ * Create a local user account, using `useradd`.
6668
67- a) Create the manifest directory
69+ * This example assumes the local user is named `userx`.
70+ * Be sure to set the user's password if the user is logging in with a
71+ password!
6872
69- $ mkdir -p /etc/puppetlabs/code/environments/production/modules/mymodule/manifests
73+ 1. Run `sudo su - root`
7074
71- b) Create `/etc/puppetlabs/code/environments/production/modules/mymodule/manifests/local_user.pp`
72- with the following content:
75+ 2. Set your `umask`.
7376
74- class mymodule::local_user (
75- Boolean $pam = simplib::lookup('simp_options::pam', { 'default_value' => false }),
76- ) {
77+ +-------------+
78+ | $ umask 022 |
79+ +-------------+
7780
78- sudo::user_specification { 'default_userx':
79- user_list => ['userx'],
80- runas => 'root',
81- # passwd => false, # only needed if user logs in without a password
82- cmnd => ['/bin/su root', '/bin/su - root']
83- }
81+ 3. Create a `local_system_access` puppet module directory and change to the
82+ directory.
8483
85- if $pam {
86- include 'pam'
84+ +-----------------------------------------------------------+
85+ | $ cd /etc/puppetlabs/code/environments/production/modules |
86+ | $ mkdir -p local_system_access/manifests |
87+ | $ cd local_system_access |
88+ +-----------------------------------------------------------+
8789
88- pam::access::rule { 'allow_userx':
89- users => ['userx'],
90- origins => ['ALL'],
91- comment => 'The local user, used to remotely login to the system in the case of a lockout.'
92- }
93- }
90+ 4. Add the following to a new `manifests/local_user.pp` file to enable
91+ `sudo su - root` and allow `ssh` access for the user you created/selected:
92+
93+ class local_system_access::local_user (
94+ Boolean $pam = simplib::lookup('simp_options::pam', { 'default_value' => false }),
95+ ) {
96+
97+ sudo::user_specification { 'default_userx':
98+ user_list => ['userx'],
99+ runas => 'root',
100+ # ONLY NEEDED IF YOUR USER DOES NOT USE A PASSWORD
101+ passwd => false,
102+ cmnd => ['/bin/su root', '/bin/su - root']
94103 }
95104
96- c) Uncomment out the `passwd` line in `sudo::user_specification` if the local
97- user is configured to login with pre-shared keys instead of a password
98- (typical cloud configuration).
105+ if $pam {
106+ include 'pam'
99107
100- 3. Create a `metadata.json` file for the module at
101- `/etc/puppetlabs/code/environments/production/modules/mymodule`.
108+ pam::access::rule { 'allow_userx':
109+ users => ['userx'],
110+ origins => ['ALL'],
111+ comment => 'Local user for lockout prevention'
112+ }
113+ }
114+ }
102115
103- * See //puppet.com/docs/puppet/latest/modules_metadata.html#metadatajson-example
104- for more information on metadata.json files.
105- * It should look something like the following:
116+ 5. Add the following to a new `metadata.json` file to enable proper
117+ recognition of your module by the puppet server:
106118
107119 {
108- "name": "mymodule ",
120+ "name": "local_system_access ",
109121 "version": "0.0.1",
110122 "author": "Your name or group here",
111123 "summary": "Configures Local User for sudo access",
@@ -124,59 +136,94 @@ class mymodule::local_user (
124136 ]
125137 }
126138
127- 4. Make sure the permissions are correct on the module:
139+ 6. Make sure the permissions are correct on the module:
140+
141+ +-----------------------------+
142+ | $ chown -R root:puppet $PWD |
143+ | $ chmod -R g+rX $PWD |
144+ +-----------------------------+
128145
129- $ sudo chown -R root:puppet /etc/puppetlabs/code/environments/production/modules/mymodule
130- $ sudo chmod -R g+rX /etc/puppetlabs/code/environments/production/modules/mymodule
146+ 7. Add the module to the SIMP server's host YAML file class list:
131147
132- 5. Add the module to the SIMP server's host YAML file class list:
148+ +--------------------------------------------------------------+
149+ | $ cd /etc/puppetlabs/code/environments/production/data/hosts |
150+ +--------------------------------------------------------------+
133151
134- Edit the SIMP server's YAML file,
135- `/etc/puppetlabs/code/environments/production/data/hosts/<SIMP server FQDN>.yaml`
136- and add the `mymodule::local_user` to the `simp::classes` array:
152+ Add `local_system_access::local_user` to the `simp::classes:` array
153+ in `<SIMP server FQDN>.yaml`
137154
138155 simp::classes:
139- - mymodule::local_user
156+ - local_system_access::local_user
157+ # Do NOT remove other items in this array
158+ # Make sure your whitespace lines up (spaces, not tabs)
140159
141- 5. If the local user is configured to login with pre-shared keys instead of a
142- password (typical cloud configuration), copy the `authorized_keys` file for
143- that user to the SIMP-managed location for authorized keys `/etc/ssh/local_keys`:
160+ 8. Add the `local_system_access` module to the `Puppetfile` in the `production`
161+ environment:
144162
145- $ sudo mkdir -p /etc/ssh/local_keys
146- $ sudo chmod 755 /etc/ssh/local_keys
147- $ sudo cp ~userx/.ssh/authorized_keys /etc/ssh/local_keys/userx
148- $ sudo chmod 644 /etc/ssh/local_keys/userx
163+ Edit `/etc/puppetlabs/code/environments/production/Puppetfile`,
164+ and add the following line under the section that says
165+ "Add your own Puppet modules here"
149166
150- 6. Add the module to the `Puppetfile` in the `production` environment:
167+ mod 'local_system_access', :local => true
151168
152- Edit the `Puppetfile` used to deploy the modules,
153- `/etc/puppetlabs/code/environments/production/Puppetfile`, and add a line
154- under the section that says "Add your own Puppet modules here"
155169
156- mod 'mymodule', :local => true
170+ -----------------------------------------
171+ If Your Local User Uses an SSH Public Key
172+ -----------------------------------------
157173
174+ * If the local user has an SSH public key available, copy the `authorized_keys`
175+ file for that user to the SIMP-managed location for authorized keys
176+ `/etc/ssh/local_keys` as shown below:
177+
178+ +------------------------------------------------------------+
179+ | $ mkdir -p /etc/ssh/local_keys |
180+ | $ chmod 755 /etc/ssh/local_keys |
181+ | $ cp ~userx/.ssh/authorized_keys /etc/ssh/local_keys/userx |
182+ | $ chmod 644 /etc/ssh/local_keys/userx |
183+ +------------------------------------------------------------+
184+
185+ ----------
158186Next Steps
159187----------
160188
161- 1. If `root` lockout is the only issue identified in this file, remove the file
162- and continue with `simp bootstrap`. If not, address any remaining issues,
163- remove the file, and then run `simp bootstrap`.
189+ DO NOT REBOOT BEFORE VERIFYING USER ACCESS
190+ USING AN ALTERNATE TERMINAL OR SSH SESSION
191+
192+ If any other issues are identified in `/root/.simp/simp_bootstrap_start_lock`,
193+ you must address them before removing the file.
194+
195+ 1. Remove the lock file and bootstrap the system
196+
197+ +--------------------------------------------+
198+ | $ rm /root/.simp/simp_bootstrap_start_lock |
199+ | $ simp bootstrap |
200+ | $ puppet agent -t |
201+ +--------------------------------------------+
202+
203+ The following items are not failures and can be ignored. All other errors or
204+ warnings should be addressed prior to proceeding:
205+
206+ * Reboot notifications.
207+ * Warning/errors related to modules that manage services you have not
208+ completely set up, such as `named`.
209+ * `svckill` warnings regarding services found that would be killed if
210+ `svckill::mode` was set to `enforcing`.
164211
165- 2. ***IMPORTANT***. After `simp bootstrap` but BEFORE you reboot the server,
166- do the following:
212+ 2. Verify user accesss
167213
168- a) Run `puppet agent -t` to verify that there are no warning or error
169- messages related to `mymodule`.
214+ * Using a NEW SSH SESSION OR TERMINAL (do NOT close your working session)
170215
171- * You will see a reboot notification which is expected and not an issue.
172- * You may see warning/errors related to other modules that manage
173- services you have not completely set up, such as `named`. These are
174- expected.
216+ * Log in as `userx`
217+ * `sudo su - root`
175218
176- b) Verify that you can ssh into the server as the new user. If you cannot,
177- do not reboot the server until you resolve the problem! This step is
178- imperative to ensure that you can also get through Puppet-managed
179- authentication.
219+ +----------------------------------------------------------------+
220+ | If your new user cannot ssh into the server and sudo to `root` |
221+ | |
222+ | * DO NOT reboot the server until you resolve the problem! |
223+ | |
224+ | * DO NOT log out of your primary work terminal |
225+ | until you resolve the problem! |
226+ +----------------------------------------------------------------+
180227DOC
181228 end
182229
0 commit comments