em-ssh 0.6.5 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b1155815fe2d0f34c5f6a9042c6affe16bb4a3d2
4
+ data.tar.gz: 3f473143a7b7e43f00f6ca7a47e9122644869248
5
+ SHA512:
6
+ metadata.gz: 2c64f15aeccde7c71cfd9c1b1e1ffca1b66a0ef44968239266a96db22ddc2748ee64b67799d35ef6b47dad42aede1f79bff91721387780c24b6586cfbc078171
7
+ data.tar.gz: a47b97dece38734b165a41ad0f2d6f5e7c86672737bb74f178db6a3c03eae3d9bb130b2abe2e31d2c6f4a15cfc17d6d1ab307af1ca8c06eb1e28a65550772ad5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ 0.7.0
2
+ - [88323761c67c433bd46fedfd042ae9a97b726cb6](https://github.com/simulacre/em-ssh/commit/88323761c67c433bd46fedfd042ae9a97b726cb6) - Deal with ssh servers that send algo data and server version at the same time (Dropbear). Discovered by [@mandre](https://github.com/mandre)
3
+
1
4
  0.6.5
2
5
  - [#26](https://github.com/simulacre/em-ssh/issues/26) - Remove echo binary
3
6
 
data/bin/em-ssh-debug ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Simple utility to print debug data for connection establishment to a remote server. Use
4
+ # this script when em-ssh is failing to properly connect to a remote server. The debug
5
+ # information can be used to troubleshoot the connection, or included in an issue ticket.
6
+
7
+ require "bundler/setup"
8
+ require 'eventmachine'
9
+ require 'em-ssh/shell'
10
+
11
+ def abort(msg)
12
+ puts msg
13
+ Process.exit
14
+ end
15
+
16
+ options = {
17
+ :prompt => /[\-\w]# /,
18
+ :port => 22
19
+ }
20
+
21
+ opts = OptionParser.new
22
+ opts.banner += " [user:[password]@]host[:port]"
23
+ opts.on('-u', '--user String', String) { |u| options[:user] = u }
24
+ opts.on('-p', '--password [String]', String) do |p|
25
+ options[:password] = p.nil? ? HighLine.new.ask("password: "){|q| q.echo = "*" } : p
26
+ end
27
+ opts.on('--prompt String', "Shell prompt [#{options[:prompt]}] to expect from the remote server") do |p|
28
+ options[:prompt] = p
29
+ end
30
+ opts.parse!
31
+
32
+ host = ARGV.shift || abort("a host is required")
33
+
34
+ options[:user], host = *host.split('@') if host.include?('@')
35
+ options[:user], options[:password] = *options[:user].split(':') if options[:user] && options[:user].include?(':')
36
+ host, options[:port] = *host.split(':') if host.include?(':')
37
+ options[:user] = ENV['USER'] unless options[:user]
38
+ options[:password] = HighLine.new.ask("#{options[:user]}'s password: "){|q| q.echo = "*" } unless options[:password]
39
+
40
+ EM.run do
41
+ options[:logger] = EM::Ssh.logger(Logger::DEBUG)
42
+ EM::Ssh::Shell.new(host, options[:user], options[:password], options) do |shell|
43
+ shell.callback do
44
+ shell.expect(options[:prompt], :timeout => 10)
45
+ EM.stop
46
+ end
47
+ shell.errback do |err|
48
+ $stderr.puts "error: #{err} (#{err.class})"
49
+ EM.stop
50
+ end
51
+ end
52
+ end
53
+
@@ -216,6 +216,12 @@ module EventMachine
216
216
  end # auth.authenticate("ssh-connection", user, options[:password])
217
217
  end.resume # Fiber
218
218
  end # :algo_init
219
+
220
+ # Some ssh servers, e.g. DropBear send the algo data immediately after sending the server version
221
+ # string without waiting for the client. In those cases the data buffer will now contain the algo
222
+ # strings, so we can't wait for the next call to #receive_data. We simulate it here to move the
223
+ # process forward.
224
+ receive_data("") unless @data.eof?
219
225
  end # :version_negotiated
220
226
 
221
227
  rescue Exception => e
@@ -19,8 +19,9 @@ module EventMachine
19
19
  cb = connection.on(:data) do |data|
20
20
  log.debug("#{self.class}.on(:data, #{data.inspect})")
21
21
  @version << data
22
- @header = @version.clone
23
- if @version[-1] == "\n"
22
+ if @version.include?("\n")
23
+ @version, _ = @version.split("\n", 2)
24
+ @header = version.clone + "\n"
24
25
  @version.chomp!
25
26
  log.debug("server version: #{@version}")
26
27
  if !@version.match(/^SSH-(1\.99|2\.0)-/)
@@ -1,5 +1,5 @@
1
1
  module EventMachine
2
2
  class Ssh
3
- VERSION='0.6.5'
4
- end # class::Ssh
5
- end # module::EventMachine
3
+ VERSION='0.7.0'
4
+ end
5
+ end
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-ssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
5
- prerelease:
4
+ version: 0.7.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Caleb Crane
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-12 00:00:00.000000000 Z
11
+ date: 2014-09-22 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: eventmachine
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: net-ssh
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: ruby-termios
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: highline
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: ''
@@ -80,15 +71,22 @@ email:
80
71
  - em-ssh@simulacre.org
81
72
  executables:
82
73
  - em-ssh
74
+ - em-ssh-debug
83
75
  - em-ssh-shell
84
76
  extensions: []
85
77
  extra_rdoc_files: []
86
78
  files:
79
+ - CHANGELOG.md
80
+ - README.md
81
+ - bin/em-ssh
82
+ - bin/em-ssh-debug
83
+ - bin/em-ssh-shell
84
+ - lib/em-ssh.rb
87
85
  - lib/em-ssh/authentication-session.rb
88
86
  - lib/em-ssh/callbacks.rb
87
+ - lib/em-ssh/connection.rb
89
88
  - lib/em-ssh/connection/channel/interactive.rb
90
89
  - lib/em-ssh/connection/channel/null-logger.rb
91
- - lib/em-ssh/connection.rb
92
90
  - lib/em-ssh/ext/net/ssh/connection/channel.rb
93
91
  - lib/em-ssh/log.rb
94
92
  - lib/em-ssh/packet-stream.rb
@@ -96,35 +94,29 @@ files:
96
94
  - lib/em-ssh/session.rb
97
95
  - lib/em-ssh/shell.rb
98
96
  - lib/em-ssh/version.rb
99
- - lib/em-ssh.rb
100
- - bin/em-ssh
101
- - bin/em-ssh-shell
102
- - CHANGELOG.md
103
- - README.md
104
97
  homepage: http://github.com/simulacre/em-ssh
105
98
  licenses:
106
99
  - MIT
100
+ metadata: {}
107
101
  post_install_message:
108
102
  rdoc_options: []
109
103
  require_paths:
110
104
  - lib
111
105
  required_ruby_version: !ruby/object:Gem::Requirement
112
- none: false
113
106
  requirements:
114
- - - ! '>='
107
+ - - ">="
115
108
  - !ruby/object:Gem::Version
116
109
  version: '0'
117
110
  required_rubygems_version: !ruby/object:Gem::Requirement
118
- none: false
119
111
  requirements:
120
- - - ! '>='
112
+ - - ">="
121
113
  - !ruby/object:Gem::Version
122
114
  version: 1.3.6
123
115
  requirements: []
124
116
  rubyforge_project:
125
- rubygems_version: 1.8.25
117
+ rubygems_version: 2.2.2
126
118
  signing_key:
127
- specification_version: 3
119
+ specification_version: 4
128
120
  summary: An EventMachine compatible net-ssh
129
121
  test_files: []
130
122
  has_rdoc: