diff --git a/lib/simp/cli/config/items/action/warn_lockout_risk_action.rb b/lib/simp/cli/config/items/action/warn_lockout_risk_action.rb index 512a4142..34910cc0 100644 --- a/lib/simp/cli/config/items/action/warn_lockout_risk_action.rb +++ b/lib/simp/cli/config/items/action/warn_lockout_risk_action.rb @@ -19,93 +19,105 @@ def initialize(puppet_env_info = DEFAULT_PUPPET_ENV_INFO) @warning_message = < false }), - ) { + +-------------+ + | $ umask 022 | + +-------------+ - sudo::user_specification { 'default_userx': - user_list => ['userx'], - runas => 'root', - # passwd => false, # only needed if user logs in without a password - cmnd => ['/bin/su root', '/bin/su - root'] - } +3. Create a `local_system_access` puppet module directory and change to the + directory. - if $pam { - include 'pam' + +-----------------------------------------------------------+ + | $ cd /etc/puppetlabs/code/environments/production/modules | + | $ mkdir -p local_system_access/manifests | + | $ cd local_system_access | + +-----------------------------------------------------------+ - pam::access::rule { 'allow_userx': - users => ['userx'], - origins => ['ALL'], - comment => 'The local user, used to remotely login to the system in the case of a lockout.' - } - } +4. Add the following to a new `manifests/local_user.pp` file to enable + `sudo su - root` and allow `ssh` access for the user you created/selected: + + class local_system_access::local_user ( + Boolean $pam = simplib::lookup('simp_options::pam', { 'default_value' => false }), + ) { + + sudo::user_specification { 'default_userx': + user_list => ['userx'], + runas => 'root', + # ONLY NEEDED IF YOUR USER DOES NOT USE A PASSWORD + passwd => false, + cmnd => ['/bin/su root', '/bin/su - root'] } - c) Uncomment out the `passwd` line in `sudo::user_specification` if the local - user is configured to login with pre-shared keys instead of a password - (typical cloud configuration). + if $pam { + include 'pam' -3. Create a `metadata.json` file for the module at - `/etc/puppetlabs/code/environments/production/modules/mymodule`. + pam::access::rule { 'allow_userx': + users => ['userx'], + origins => ['ALL'], + comment => 'Local user for lockout prevention' + } + } + } - * See //puppet.com/docs/puppet/latest/modules_metadata.html#metadatajson-example - for more information on metadata.json files. - * It should look something like the following: +5. Add the following to a new `metadata.json` file to enable proper + recognition of your module by the puppet server: { - "name": "mymodule", + "name": "local_system_access", "version": "0.0.1", "author": "Your name or group here", "summary": "Configures Local User for sudo access", @@ -124,59 +136,94 @@ class mymodule::local_user ( ] } -4. Make sure the permissions are correct on the module: +6. Make sure the permissions are correct on the module: + + +-----------------------------+ + | $ chown -R root:puppet $PWD | + | $ chmod -R g+rX $PWD | + +-----------------------------+ - $ sudo chown -R root:puppet /etc/puppetlabs/code/environments/production/modules/mymodule - $ sudo chmod -R g+rX /etc/puppetlabs/code/environments/production/modules/mymodule +7. Add the module to the SIMP server's host YAML file class list: -5. Add the module to the SIMP server's host YAML file class list: + +--------------------------------------------------------------+ + | $ cd /etc/puppetlabs/code/environments/production/data/hosts | + +--------------------------------------------------------------+ - Edit the SIMP server's YAML file, - `/etc/puppetlabs/code/environments/production/data/hosts/.yaml` - and add the `mymodule::local_user` to the `simp::classes` array: + Add `local_system_access::local_user` to the `simp::classes:` array + in `.yaml` simp::classes: - - mymodule::local_user + - local_system_access::local_user + # Do NOT remove other items in this array + # Make sure your whitespace lines up (spaces, not tabs) -5. If the local user is configured to login with pre-shared keys instead of a - password (typical cloud configuration), copy the `authorized_keys` file for - that user to the SIMP-managed location for authorized keys `/etc/ssh/local_keys`: +8. Add the `local_system_access` module to the `Puppetfile` in the `production` + environment: - $ sudo mkdir -p /etc/ssh/local_keys - $ sudo chmod 755 /etc/ssh/local_keys - $ sudo cp ~userx/.ssh/authorized_keys /etc/ssh/local_keys/userx - $ sudo chmod 644 /etc/ssh/local_keys/userx + Edit `/etc/puppetlabs/code/environments/production/Puppetfile`, + and add the following line under the section that says + "Add your own Puppet modules here" -6. Add the module to the `Puppetfile` in the `production` environment: + mod 'local_system_access', :local => true - Edit the `Puppetfile` used to deploy the modules, - `/etc/puppetlabs/code/environments/production/Puppetfile`, and add a line - under the section that says "Add your own Puppet modules here" - mod 'mymodule', :local => true +----------------------------------------- +If Your Local User Uses an SSH Public Key +----------------------------------------- +* If the local user has an SSH public key available, copy the `authorized_keys` + file for that user to the SIMP-managed location for authorized keys + `/etc/ssh/local_keys` as shown below: + + +------------------------------------------------------------+ + | $ mkdir -p /etc/ssh/local_keys | + | $ chmod 755 /etc/ssh/local_keys | + | $ cp ~userx/.ssh/authorized_keys /etc/ssh/local_keys/userx | + | $ chmod 644 /etc/ssh/local_keys/userx | + +------------------------------------------------------------+ + +---------- Next Steps ---------- -1. If `root` lockout is the only issue identified in this file, remove the file - and continue with `simp bootstrap`. If not, address any remaining issues, - remove the file, and then run `simp bootstrap`. +DO NOT REBOOT BEFORE VERIFYING USER ACCESS +USING AN ALTERNATE TERMINAL OR SSH SESSION + +If any other issues are identified in `/root/.simp/simp_bootstrap_start_lock`, +you must address them before removing the file. + +1. Remove the lock file and bootstrap the system + + +--------------------------------------------+ + | $ rm /root/.simp/simp_bootstrap_start_lock | + | $ simp bootstrap | + | $ puppet agent -t | + +--------------------------------------------+ + + The following items are not failures and can be ignored. All other errors or + warnings should be addressed prior to proceeding: + + * Reboot notifications. + * Warning/errors related to modules that manage services you have not + completely set up, such as `named`. + * `svckill` warnings regarding services found that would be killed if + `svckill::mode` was set to `enforcing`. -2. ***IMPORTANT***. After `simp bootstrap` but BEFORE you reboot the server, - do the following: +2. Verify user accesss - a) Run `puppet agent -t` to verify that there are no warning or error - messages related to `mymodule`. + * Using a NEW SSH SESSION OR TERMINAL (do NOT close your working session) - * You will see a reboot notification which is expected and not an issue. - * You may see warning/errors related to other modules that manage - services you have not completely set up, such as `named`. These are - expected. + * Log in as `userx` + * `sudo su - root` - b) Verify that you can ssh into the server as the new user. If you cannot, - do not reboot the server until you resolve the problem! This step is - imperative to ensure that you can also get through Puppet-managed - authentication. ++----------------------------------------------------------------+ +| If your new user cannot ssh into the server and sudo to `root` | +| | +| * DO NOT reboot the server until you resolve the problem! | +| | +| * DO NOT log out of your primary work terminal | +| until you resolve the problem! | ++----------------------------------------------------------------+ DOC end