puppetlabs / puppetlabs/puppetlabs-sshkeys_core

support read-only authorized_keys

Open
#92 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Ruby
Stars
3
Forks
34
PR merge metrics
No merged PRs in 30d

Description

Use Case

I am trying to deploy keys that are not writable by the UNIX user they are for. In our configuration, we have a hardened SSH configuration that keeps users from modifying their own SSH keys:

AuthorizedKeysFile /etc/ssh/userkeys/%u /var/lib/misc/userkeys/%u /etc/ssh/userkeys/%u.more /etc/ssh/puppetkeys/%u

Unfortunately, the way the ssh_authorized_key type operates now is that it hardcodes the mode (0600) of the file and also the owner (whatever the user selected). So an operator has two choices, either:

-make the file owned by the user, in which case authentication works but the keys are modifiable by the user, or;

  • make the file owned by root, in which case the file is not writable by the user but authentication then fails because it's not readable either

Describe the Solution You Would Like

I don't actually see why authorized_keys are 0600: they are public keys, who cares if someone reads the darn thing? Perhaps there's some leakage in the key comment, as it shows where the private key is stored and could be used for lateral movement, but the benefit of that is very much completely voided by having the authorized_keys file modifiable by the user.

Describe Alternatives You've Considered

So far, we're doing this horror:

  ensure_resource('file', "/etc/ssh/userkeys/${sandbox_user}", {
    ensure => $ensure,
    owner => 'root',
    mode  => '0444',
  })

It's not great, as we have overlapping File resources and it can cause flapping.

Additional Context

This was originally filed as MODULES-9726 and ignored for two years, then closed as not being a priority.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the ssh_authorized_key type and the code that sets its file owner and mode. Trace the existing tests for authorized_keys permissions, then define behavior that permits root-owned files to remain readable without being writable by the target user and avoids overlapping File resources.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
authentication, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.