public
Created

disabling a user by turning off their ssh access and disabling the password

  • Download Gist
disabled_user.json
JSON
1 2 3 4 5 6 7 8 9
{
"id": "bofh",
"ssh_keys": "ssh-rsa AAAAB3Nz...yhCw== bofh",
"groups": "sysadmin",
"uid": 2001,
"shell": "\/bin\/bash",
"comment": "BOFH",
"diabled": true
}
sysadmins.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
user u['id'] do
uid u['uid']
gid u['gid']
shell u['shell']
comment u['comment']
supports :manage_home => true
home home_dir
action u['disabled'] ? :lock : :create
notifies :create, "ruby_block[reset group list]", :immediately
end
 
 
if u['disabled']
file "#{home_dir}/.ssh/authorized_keys" do
action :delete
end
else
template "#{home_dir}/.ssh/authorized_keys" do
source "authorized_keys.erb"
owner u['id']
group u['gid'] || u['id']
mode "0600"
variables :ssh_keys => u['ssh_keys']
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.