Skip to content

Instantly share code, notes, and snippets.

@3dd13
Created January 20, 2011 16:59
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save 3dd13/788178 to your computer and use it in GitHub Desktop.
Save 3dd13/788178 to your computer and use it in GitHub Desktop.
chef recipe to generate ssh key for a user
define :generate_ssh_keys, :user_account => nil do
username = params[:user_account]
raise ":user_account should be provided." if username.nil?
Chef::Log.debug("generate ssh skys for #{username}.")
execute "generate ssh skys for #{username}." do
user username
creates "/home/#{username}/.ssh/id_rsa.pub"
command "ssh-keygen -t rsa -q -f /home/#{username}/.ssh/id_rsa -P \"\""
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment