RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2178612 - Add a SELinux boolean which allows qemu guest agent to write SSH keys
Summary: Add a SELinux boolean which allows qemu guest agent to write SSH keys
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: selinux-policy
Version: 9.2
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Nikola Knazekova
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks: 2179027
TreeView+ depends on / blocked
 
Reported: 2023-03-15 12:30 UTC by Andrej Krejcir
Modified: 2023-05-10 12:53 UTC (History)
9 users (show)

Fixed In Version: selinux-policy-38.1.9-1.el9_2
Doc Type: Enhancement
Doc Text:
Feature: Add SELinux boolean to allow qemu guest agent to manage SSH keys Reason: QEMU Guest Agent 5.2.0 added some new features including commands for managing guest ssh keys. Result: QEMU Guest Agent can manage ssh home directory by enabling the virt_qemu_ga_manage_ssh SELinux boolean.
Clone Of:
: 2179027 (view as bug list)
Environment:
Last Closed: 2023-05-09 08:17:18 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-151927 0 None None None 2023-03-15 12:32:43 UTC
Red Hat Product Errata RHBA-2023:2483 0 None None None 2023-05-09 08:17:24 UTC

Description Andrej Krejcir 2023-03-15 12:30:04 UTC
Description of problem:

By default selinux blocks qemu guest agent from accessing SSH key files.
Currently there is a boolean to allow reading keys "virt_qemu_ga_read_ssh", but there is no boolean to allow writing keys.

Version-Release number of selected component (if applicable):
selinux-policy  38.1.8-1.el9 

How reproducible:
100%

Steps to Reproduce:
1. Start a VM with RHEL 9.2 guest image. I've used "rhel-guest-image-9.2-20230220.9.x86_64.qcow2"

virt-customize -a rhel-9.2.qcow2 \
  --ssh-inject root \
  --root-password password:pass123 \
  --uninstall cloud-init \
  --connect qemu:///system

virt-install --name test-vm \
  --vcpus 2 \
  --cpu host \
  --memory 2048 \
  --rng /dev/urandom \
  --disk rhel-9.2.qcow2 \
  --os-variant=rhel9.0 \
  --import \
  --boot uefi \
  --noautoconsole \
  --connect qemu:///system


2. Try to set SSH keys using qemu guest agent.
virsh -c qemu:///system set-user-sshkeys test-vm root --file ~/.ssh/id_rsa.pub

Fails with error message:
error: internal error: unable to execute QEMU agent command 'guest-ssh-add-authorized-keys': failed to write to '/root/.ssh/authorized_keys': Failed to create file “/root/.ssh/authorized_keys.SUES11”: Permission denied


Additional info:

Reading the keys fails similarly, if the "virt_qemu_ga_read_ssh" boolean is not set in the guest.

virsh -c qemu:///system get-user-sshkeys test-vm root

fails with:
error: internal error: unable to execute QEMU agent command 'guest-ssh-get-authorized-keys': failed to read '/root/.ssh/authorized_keys': Failed to open file “/root/.ssh/authorized_keys”: Permission denied


After the boolean is set,

virsh -c qemu:///system get-user-sshkeys test-vm root

Succeeds and prints the key.

Comment 21 errata-xmlrpc 2023-05-09 08:17:18 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (selinux-policy bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2483


Note You need to log in before you can comment on or make changes to this bug.