ssh-copy-id.rb 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,7 +43,7 @@ module SSHCopyID
43
43
  def self.execute options, ask_password
44
44
  identity_file = options[:identity] || DEFAULT_IDENTITY_FILE
45
45
  identity = File.readlines(File.expand_path identity_file).first.chomp
46
- password = options[:password]
46
+ passwords = {}
47
47
  output = options[:output] || Class.new { def method_missing *args; end }.new
48
48
 
49
49
  options[:hosts].each do |host|
@@ -51,13 +51,21 @@ module SSHCopyID
51
51
  user, pass = user.split(':') if user
52
52
  user ||= options[:username] || ENV['USER']
53
53
  output.print "#{user}@#{host}: "
54
- if pass.nil? && password.nil? && (ask_password || options.has_key?(:password))
55
- password = HighLine.new.ask($/ + "Password: ") { |q| q.echo = '*' }
56
- end
57
- pass ||= password
54
+ password =
55
+ if pass
56
+ pass
57
+ elsif options[:password]
58
+ options[:password]
59
+ elsif passwords[user]
60
+ passwords[user]
61
+ elsif ask_password || options.has_key?(:password)
62
+ passwords[user] = HighLine.new.ask($/ + "Password: ") { |q| q.echo = '*' }
63
+ else
64
+ nil
65
+ end
58
66
 
59
67
  host, port = host.split(':')
60
- Net::SSH.start(host, user, :port => port, :password => pass) do |ssh|
68
+ Net::SSH.start(host, user, :port => port, :password => password) do |ssh|
61
69
  result = ssh.exec!(yield identity)
62
70
  output.puts result
63
71
  end
@@ -1,3 +1,3 @@
1
1
  module SSHCopyID
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssh-copy-id.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-16 00:00:00.000000000 Z
12
+ date: 2013-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh
@@ -83,10 +83,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 1.8.24
86
+ rubygems_version: 1.8.25
87
87
  signing_key:
88
88
  specification_version: 3
89
89
  summary: ssh-copy-id in Ruby. Supports copying to multiple servers.
90
90
  test_files:
91
91
  - test/bin_helper.rb
92
- has_rdoc: