Sha256: 5712c9bba47bbb79dbdc84211c8f10497df54f27a6b3c873d04f8dfa5da19f99
Contents?: true
Size: 649 Bytes
Versions: 17
Compression:
Stored size: 649 Bytes
Contents
module AwsEc2::Template::Helper::SshKeyHelper def add_ssh_key(user="ec2-user") key_path = "#{ENV['HOME']}/.ssh/id_rsa.pub" if File.exist?(key_path) public_key = IO.read(key_path).strip end if public_key <<-SCRIPT # Automatically add user's public key from #{key_path} cp /home/#{user}/.ssh/authorized_keys{,.bak} echo #{public_key} >> /home/#{user}/.ssh/authorized_keys chown #{user}:#{user} /home/#{user}/.ssh/authorized_keys SCRIPT else <<-SCRIPT # WARN: unable to find a ~/.ssh/id_rsa.pub locally on your machine. user: #{ENV['USER']} # Unable to automatically add the public key SCRIPT end end end
Version data entries
17 entries across 17 versions & 1 rubygems