Jira (PUP-11072) purge_ssh_keys does not work if the key is owned by root

17 views
Skip to first unread message

Martin Alfke (Jira)

unread,
May 28, 2021, 1:17:27 PM5/28/21
to puppe...@googlegroups.com
Martin Alfke created an issue
 
Puppet / Bug PUP-11072
purge_ssh_keys does not work if the key is owned by root
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2021/05/26 6:53 AM
Priority: Normal Normal
Reporter: Martin Alfke

Puppet Version: any
Puppet Server Version: unrelated
OS Name/Version: any Linux system using SSH

In a secured environment ssh keys may not be in users home, but must be located in root context (e.g. /etc/ssh/keys/<user key file>

Besides this it is forbidden for a user to add a new key or remove an old key. Therefor the key files must be owned by root user using 0644 as access mode.

When using purge_ssh_keys => ["/etc/ssh/keys/${user}"] the removal of ssh keys fails, as Puppet wants to delete the key using user privileges.

Reason is a hard-coded setting in puppet type:

# lib/puppet/type/user.rb line 785 and following:
    def find_unmanaged_keys
      self[:purge_ssh_keys].
        select { |f| File.readable?(f) }.
        map { |f| unknown_keys_in_file(f) }.
        flatten.each do |res|
          res[:ensure] = :absent
          res[:user] = self[:name]          # <---------- !!!!!
          @parameters.each do |name, param|
            res[name] = param.value if param.metaparam?
          end
        end
    end

Desired Behavior:

Any unmanaged key gets removed.

Actual Behavior:

Puppet throws an error, that it can not change the file.

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages