Created
August 18, 2011 22:38
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "bofh", | |
"ssh_keys": "ssh-rsa AAAAB3Nz...yhCw== bofh", | |
"groups": "sysadmin", | |
"uid": 2001, | |
"shell": "\/bin\/bash", | |
"comment": "BOFH", | |
"diabled": true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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