Skip to content

Instantly share code, notes, and snippets.

@jtimberman
Created August 18, 2011 22:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtimberman/1155453 to your computer and use it in GitHub Desktop.
Save jtimberman/1155453 to your computer and use it in GitHub Desktop.
disabling a user by turning off their ssh access and disabling the password
{
"id": "bofh",
"ssh_keys": "ssh-rsa AAAAB3Nz...yhCw== bofh",
"groups": "sysadmin",
"uid": 2001,
"shell": "\/bin\/bash",
"comment": "BOFH",
"diabled": true
}
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment