Sha256: f6783da5fcdda4b5f308b773d50fea85133a2daea41f73ae43f4568008d191bb
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'rubygems' require 'net/scp' require 'yaml' module SshKeyMan class Uploader # upload authorized_keys for a specific group # def self.upload_all_public_keys group authorized_keys = File.join(".", "authorized_keys") upload_to_all_servers authorized_keys, "~/.ssh/", group end # upload file to a group of servers # def self.upload_to_all_servers source, dest, group server_list_path = File.join(".", "server_list.yml") servers = YAML::load_file(server_list_path)['servers'][group] raise "No Server Group: #{group}" if servers.size == 0 servers.each do |server_info| upload! server_info["host"], server_info["port"]||"22", server_info["user"], source, dest end end # upload a file to a remote server # def self.upload! host, port, user, source, dest puts "coping file from #{source} to #{user}@#{host}:#{dest}" `scp -P #{port} #{source} #{user}@#{host}:#{dest}` raise "upload failed" if $?.exitstatus != 0 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ssh-key-sync-man-0.2.0 | lib/uploader.rb |