Bugzilla (bugzilla.redhat.com) will be under maintenance for infrastructure upgrades and will not be unavailable on July 31st between 12:30 AM - 05:30 AM UTC. We appreciate your understanding and patience. You can follow status.redhat.com for details.
Bug 529275 - ssh-copy-id leaves ~/.ssh/ with wrong context
Summary: ssh-copy-id leaves ~/.ssh/ with wrong context
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: 11
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Ben Levenson
Depends On:
TreeView+ depends on / blocked
Reported: 2009-10-15 20:38 UTC by Stephen Tweedie
Modified: 2010-04-30 12:55 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2010-04-28 18:54:09 UTC
Type: ---

Attachments (Terms of Use)

Description Stephen Tweedie 2009-10-15 20:38:36 UTC
Description of problem:
I used F10 to ssh-copy-id an ssh public key to a freshly-provisioned, up-to-date F11 virtual guest.  The process worked, but left the guest's /root/.ssh and /root/.ssh/authorized_keys with the wrong context, so subsequent ssh to the guest failed.

Version-Release number of selected component (if applicable):

How reproducible:
100%, I expect

Steps to Reproduce:
1.ssh-copy-id to a user without an existing ~/.ssh (I used root in this case, not sure if an unprivileged user would behave differently)
2.ssh to the same user
Actual results:
AVC denials, and the ssh fails

Expected results:
ssh should succeed

Additional info:
A restorecon -vR ~/.ssh fixes the problem.

Full setroubleshoot info:
Source Context:		system_u:system_r:sshd_t:s0-s0:c0.c1023
Target Context:		unconfined_u:object_r:admin_home_t:s0
Target Objects:		authorized_keys [ file ]
Source:			sshd
Source Path:		<Unknown>
Port:			<Unknown>
Host:			f11.kvm.darkstar.scot.redhat.com
Source RPM Packages:		
Target RPM Packages:		
Policy RPM:		selinux-policy-3.6.12-85.fc11
Selinux Enabled:	True
Policy Type:		targeted
MLS Enabled:		True
Enforcing Mode:		Enforcing
Plugin Name:		home_tmp_bad_labels
Host Name:		f11.kvm.darkstar.scot.redhat.com
Platform:		Linux f11.kvm.darkstar.scot.redhat.com #1 SMP Fri Sep 25 04:56:58 EDT 2009 i686 i686
Alert Count:		2
First Seen:		Thu 15 Oct 2009 12:05:42 PM BST
Last Seen:		Thu 15 Oct 2009 12:05:42 PM BST
Local ID:		d976035c-0de8-4bcb-bd4a-bbbc12ab08d1
Line Numbers:		
Raw Audit Messages :

node=f11.kvm.darkstar.scot.redhat.com type=AVC msg=audit(1255604742.976:21959): avc: denied { read } for pid=2272 comm="sshd" name="authorized_keys" dev=dm-0 ino=19590 
scontext=system_u:system_r:sshd_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file

Comment 2 Daniel Walsh 2009-10-15 21:19:00 UTC
This is fixed in F12.

Miroslav add

# ssh servers can read the user keys and config
manage_dirs_pattern(ssh_server, home_ssh_t, home_ssh_t)
manage_files_pattern(ssh_server, home_ssh_t, home_ssh_t)
userdom_user_home_dir_filetrans(ssh_server, home_ssh_t, dir)
userdom_admin_home_dir_filetrans(ssh_server, home_ssh_t, dir)

Comment 3 Miroslav Grepl 2009-10-16 09:50:36 UTC
Strange since rules have been added to selinux-policy-3.6.12-84. I am going to test it.

Comment 4 Bug Zapper 2010-04-28 10:51:05 UTC
This message is a reminder that Fedora 11 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 11.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '11'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 11's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 11 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 

Comment 5 Stephen Tweedie 2010-04-30 12:55:17 UTC
Just re-tested in F13-beta, and I can confirm it's working fine there.

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