Sha256: 83bf52fd1c5fe802a582d4aa9619f70e015042a83f157e080b1ad37060097ed5
Contents?: true
Size: 1000 Bytes
Versions: 3
Compression:
Stored size: 1000 Bytes
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["user"], source, dest end end # upload a file to a remote server # def self.upload! host, user, source, dest puts "coping file from #{source} to #{user}@#{host}:#{dest}" `scp #{source} #{user}@#{host}:#{dest}` raise "upload failed" if $?.exitstatus != 0 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ssh-key-sync-man-0.1.5 | lib/uploader.rb |
ssh-key-sync-man-0.1.4 | lib/uploader.rb |
ssh-key-sync-man-0.1.3 | lib/uploader.rb |