chef-user icon indicating copy to clipboard operation
chef-user copied to clipboard

Issue modifying ssh keys for root users

Open nicolasccit opened this issue 12 years ago • 2 comments

When I want to create a new user like so:

user_account 'new_user' do
  ssh_keys "ssh-rsa ..."
  action :create
end

Everything works as planned.

But when I try the following:

user_account 'root' do
  ssh_keys "ssh-rsa ..."
  action :modify
end

I get the following error:

Error executing action modify on resource 'user_account[root]'

Chef::Exceptions::Exec

user[root](/var/chef/cache/cookbooks/user/providers/account.rb line 94) had an error: Chef::Exceptions::Exec: usermod -m -d '/home/root' root returned 8, expected 0

Cookbook Trace:

/var/chef/cache/cookbooks/user/providers/account.rb:105:in user_resource' /var/chef/cache/cookbooks/user/providers/account.rb:46:inblock in class_from_file'

Resource Declaration:

In /var/chef/cache/cookbooks/rollcall/recipes/default.rb

13: user_account 'root' do 14: ssh_keys "ssh-rsa ..." 15: action :modify 16: end 17:

Compiled Resource:

Declared in /var/chef/cache/cookbooks/rollcall/recipes/default.rb:13:in `from_file'

user_account("root") do action [:modify] retries 0 retry_delay 2 cookbook_name "rollcall" recipe_name "default" ssh_keys "ssh-rsa ..." username "root" end

Any idea what I'm doing wrong?

Thanks, Nicolas

nicolasccit avatar Jun 17 '13 18:06 nicolasccit

I had a similar problem when trying to mange authorized_keys for root. I found that adding home '/root' and manage_home falsefixed things.

My block now looks like this :

user_account 'root' do
    home '/root'
    manage_home false
    ssh_keys ['ssh-rsa key_1', 'ssh-rsa key_2']
    action :modify
end

mckelvaney avatar Jul 23 '13 14:07 mckelvaney

Thanks for posting your fix @mckelvaney

...I had the same problem too.

eamonnfaherty avatar Oct 16 '13 16:10 eamonnfaherty