Sha256: c26a3eeb256e813546ddad1b7726c243f935b0e1640cd00cd9fe20a0fbe447b1
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
namespace :sshd do desc <<-DESC Create public and private keys for ssh. "Source":#{link_to_source(__FILE__)} DESC task_arg(:ssh_keygen_type, "SSH keygen type", :default => "rsa") task_arg(:ssh_keygen_bits, "SSH keygen bits", :default => 2048) task :keygen do run "ssh-keygen -t #{ssh_keygen_type} -b #{ssh_keygen_bits}" do |channel, stream, data| logger.trace data if data =~ /^Overwrite (y\/n)?/ channel.send_data "n\n" logger.important "This key already exists! Aborting." # Use default for file and empty password elsif data =~ /^Enter file/ or data =~ /^Enter passphrase/ or data =~ /^Enter same passphrase again/ channel.send_data "\n" end end end desc <<-DESC Add to authorized keys. Uses @.ssh/authorized_keys@. "Source":#{link_to_source(__FILE__)} DESC task_arg(:ssh_public_key, "The public key from sshd:keygen") task_arg(:ssh_dir, "SSH home directory", :default => "~/.ssh") task_arg(:authorized_keys_path, "Path to authorized keys", :default => "~/.ssh/authorized_keys") task :authorize_key do run_all <<-CMDS if [ ! -d #{ssh_dir} ]; then mkdir #{ssh_dir} ; chmod 700 #{ssh_dir} ; fi if [ ! -f #{authorized_keys_path} ]; then touch #{authorized_keys_path} ; chmod 600 #{authorized_keys_path} ; fi echo "#{ssh_public_key}" >> #{authorized_keys_path} CMDS end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
calas-capitate-0.3.6 | lib/recipes/sshd.rb |
capitate-0.3.6 | lib/recipes/sshd.rb |