canonical / canonical/cloud-init

Adding and reporting ssh keys fails for user in extrausers

Open
#2,851 0 comments 0 reactions 0 assignees View on GitHub
bug launchpad
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

This bug was originally filed in Launchpad as [LP: #1679777](https://bugs.launchpad.net/cloud-init/+bug/1679777)

Launchpad details

affected_projects = []

assignee = None
assignee_name = None
date_closed = None
date_created = 2017-04-04T17:16:12.128372+00:00
date_fix_committed = None
date_fix_released = None
id = 1679777
importance = medium
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1679777
milestone = None
owner = smoser
owner_name = Scott Moser
private = False
status = confirmed
submitter = smoser
submitter_name = Scott Moser
tags = []
duplicates = []

_Launchpad user **Scott Moser(smoser)** wrote on 2017-04-04T17:16:12.128372+00:00_

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 () failed
2017-04-04 16:57:04,560 - util.py[DEBUG]: Running module ssh-authkey-fingerprints () 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.