lib/clearsight/ssh.rb in clearsight-1.2.0.rc2 vs lib/clearsight/ssh.rb in clearsight-1.2.0
- old
+ new
@@ -1,14 +1,22 @@
module Clearsight
class SSH
+ include Methadone::CLILogging
+ include Methadone::SH
def initialize(host)
@host = host
end
def sshify(keyname)
- # sh "cat ~/.ssh/#{keyname} | ssh #{host} 'cat >> ~/.ssh/authorized_keys'"
- sh "ssh-copy-id -i ~/.ssh/#{keyname} #{@host}"
+ commands = [
+ "mkdir -p ~/.ssh",
+ "touch ~/.ssh/authorized_keys",
+ "chmod 744 ~/.ssh",
+ "chmod 644 ~/.ssh/authorized_keys",
+ "cat >> ~/.ssh/authorized_keys",
+ ]
+ sh "cat ~/.ssh/#{keyname} | ssh #{@host} '#{commands.join("; ")}'"
end
end
end
Clearsight::Ssh = Clearsight::SSH