Ask Your Question
0

Possible to change file permission (mode) multiple times?

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

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

Comments

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 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

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

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

Comments

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 -0500 )edit
0

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

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.

https://github.com/nightfly19/puppet-ssh_keys

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

Stats

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

Seen: 535 times

Last updated: Aug 30 '13