Adding and reporting ssh keys fails for user in extrausers

Bug #1679777 reported by Scott Moser
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
cloud-init
Expired
Medium
Unassigned

Bug Description

If a user is added with '--extrausers' (which happens on ubuntu core)
then adding ssh keys or reporting which keys are added will fail as the users cannot be found.
This seems a general issue as extrausers, see bug 1679765.

The stack trace looks like:

2017-04-04 16:57:00,117 - util.py[WARNING]: Applying ssh credentials failed!
2017-04-04 16:57:00,117 - util.py[DEBUG]: Applying ssh credentials failed!
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_ssh.py", line 195, in handle
    apply_credentials(keys, user, disable_root, disable_root_opts)
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_ssh.py", line 204, in apply_credentials
    ssh_util.setup_user_keys(keys, user)
  File "/usr/lib/python3/dist-packages/cloudinit/ssh_util.py", line 241, in setup_user_keys
    (ssh_dir, pwent) = users_ssh_info(username)
  File "/usr/lib/python3/dist-packages/cloudinit/ssh_util.py", line 205, in users_ssh_info
    pw_ent = pwd.getpwnam(username)
KeyError: 'getpwnam(): name not found: ubuntu'

and then

2017-04-04 16:57:04,559 - util.py[WARNING]: Running module ssh-authkey-fingerprints (<module 'cloudinit.config.cc_ssh_authkey_fingerprints' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_ssh_authkey_fingerprints.py'>) failed
2017-04-04 16:57:04,560 - util.py[DEBUG]: Running module ssh-authkey-fingerprints (<module 'cloudinit.config.cc_ssh_authkey_fingerprints' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_ssh_authkey_fingerprints.py'>) failed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 787, in _run_modules
    freq=freq)
  File "/usr/lib/python3/dist-packages/cloudinit/cloud.py", line 54, in run
    return self._runners.run(name, functor, args, freq, clear_on_fail)
  File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 187, in run
    results = functor(*args)
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_ssh_authkey_fingerprints.py", line 108, in handle
    (key_fn, key_entries) = ssh_util.extract_authorized_keys(user_name)
  File "/usr/lib/python3/dist-packages/cloudinit/ssh_util.py", line 212, in extract_authorized_keys
    (ssh_dir, pw_ent) = users_ssh_info(username)
  File "/usr/lib/python3/dist-packages/cloudinit/ssh_util.py", line 205, in users_ssh_info
    pw_ent = pwd.getpwnam(username)
KeyError: 'getpwnam(): name not found: ubuntu'

Related bugs:
 * bug 1679765: cannot lock password for user created with useradd --extrausers

Scott Moser (smoser)
Changed in cloud-init:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
James Falcon (falcojr) wrote :
Changed in cloud-init:
status: Confirmed → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.