Sha256: 45387160164c3b40c655de19b55dfbdc6b8732fb7dc0983a3d9e32224a44b8fb
Contents?: true
Size: 1017 Bytes
Versions: 43
Compression:
Stored size: 1017 Bytes
Contents
module Incline class CLI class Prepare private def ssh_copy_id(shell) my_id_file = File.expand_path('~/.ssh/rsa_id.pub') if File.exist?(my_id_file) my_id = File.read(my_id_file) shell.with_stat('Enabling public key authentication') do shell.exec 'if [ ! -d ~/.ssh ]; then mkdir ~/.ssh; fi' shell.exec 'chmod 700 ~/.ssh' contents = shell.read_file("#{shell.home_path}/.ssh/authorized_keys") if contents unless contents.split("\n").find{|k| k.to_s.strip == my_id.strip} contents += "\n" unless contents[-1] == "\n" contents += my_id.strip + "\n" shell.write_file("#{shell.home_path}/.ssh/authorized_keys", contents) end else shell.write_file("#{shell.home_path}/.ssh/authorized_keys", my_id + "\n") end end end end end end end
Version data entries
43 entries across 43 versions & 1 rubygems