Ask Your Question

Possible to change file permission (mode) multiple times?

asked 2013-08-30 12:53:32 -0600

Rodney gravatar image

I've run into an issue where using sshauthorizedkey fails if the target ~/.ssh/authorized_keys file is read-only (mode 0400).

FYI: The error is Sshauthorizedkey[username]) Could not evaluate: Puppet::Util::FileType::FileTypeFlat could not write /home/username/.ssh/authorizedkeys: Permission denied - /home/username/.ssh/authorizedkeys

One idea I had was if I could do a file resource that changed the permission to writable, performed the Sshauthorizedkey, and then another file resource that changed it back to read-only. You can't duplicate resources though so I'm not sure if this could ... (more)

edit retag flag offensive close merge delete


I'm not exactly sure what you're gaining by 400 vs 600 here. Why not just go with 0600? Your best bet might be to just fork the sshauthorizedkey ...(more)

Trevor Vaughan gravatar imageTrevor Vaughan ( 2013-09-01 13:16:06 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-08-30 12:58:40 -0600

Ancillas gravatar image

You'd have to use an Exec resource to run chmod against the file as a workaround to not being able to have the same File resource in the catalog twice.

edit flag offensive delete link more


While sometimes necessary, this isn't ideal since the idea of Puppet is that you describe a state which Puppet enforces. Unfortunately, this falls into a gray area where sometimes ...(more)

Ancillas gravatar imageAncillas ( 2013-08-30 12:59:52 -0600 )edit

answered 2013-08-30 17:20:55 -0600

nibalizer gravatar image

Nightfly19 has made a puppet module for managing ssh keys based on the concat module. I believe it will allow you to manage the authorized_keys file to have a value of 400.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-08-30 12:53:32 -0600

Seen: 789 times

Last updated: Aug 30 '13