Sha256: 42c5db6bc6749d6ea0040df1ef2d3f8c0927e90a221fb373e47edde561df657b

Contents?: true

Size: 648 Bytes

Versions: 14

Compression:

Stored size: 648 Bytes

Contents

load File.expand_path("../set_rails_env.rake", __FILE__)

namespace :ssh do
  desc 'Adds public key to the authorized_keys file (to enable passwordless login)'
  task :add_key do
    ask(:key, 'SSH public key')
    on roles(:all) do |host|
      # this script depends on the HOME environment variable to be set
      home = capture("env | grep HOME").split('=').last
      within home do
        remote_keys = capture(:cat, '.ssh/authorized_keys')
        keys = remote_keys.split("\n")
        keys << fetch(:key) + "\n"
        new_keys = StringIO.new(keys.join("\n"))
        upload! new_keys, '.ssh/authorized_keys'
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
capistrano-devops-0.0.15 lib/capistrano/tasks/ssh.rake
capistrano-devops-0.0.14 lib/capistrano/tasks/ssh.rake
capistrano-devops-0.0.13 lib/capistrano/tasks/ssh.rake
capistrano-devops-0.0.12 lib/capistrano/tasks/ssh.rake
capistrano-devops-0.0.11 lib/capistrano/tasks/ssh.rake
capistrano-devops-0.0.10 lib/capistrano/tasks/ssh.rake
capistrano-devops-0.0.9 lib/capistrano/tasks/ssh.rake
capistrano-devops-0.0.8 lib/capistrano/tasks/ssh.rake
capistrano-devops-0.0.7 lib/capistrano/tasks/ssh.rake
capistrano-devops-0.0.6 lib/capistrano/tasks/ssh.rake
capistrano-devops-0.0.5 lib/capistrano/tasks/ssh.rake
capistrano-devops-0.0.4 lib/capistrano/tasks/ssh.rake
capistrano-devops-0.0.3 lib/capistrano/tasks/ssh.rake
capistrano-devops-0.0.2 lib/capistrano/tasks/ssh.rake