net-ssh 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/manual/manual.rb +2 -2
- data/doc/manual/parts/intro_what_is.txt +0 -2
- data/lib/net/ssh/connection/channel.rb +42 -3
- data/lib/net/ssh/service/forward/driver.rb +1 -1
- data/lib/net/ssh/service/forward/local-network-handler.rb +10 -13
- data/lib/net/ssh/service/forward/remote-network-handler.rb +5 -3
- data/lib/net/ssh/transport/packet-stream.rb +25 -11
- data/lib/net/ssh/transport/session.rb +10 -2
- data/lib/net/ssh/userauth/driver.rb +7 -0
- data/lib/net/ssh/userauth/methods/services.rb +14 -9
- data/lib/net/ssh/version.rb +2 -2
- data/test/connection/tc_channel.rb +2 -2
- data/test/proxy/tc_http.rb +1 -1
- data/test/proxy/tc_socks4.rb +1 -1
- data/test/proxy/tc_socks5.rb +1 -1
- data/test/service/forward/tc_remote_network_handler.rb +5 -2
- metadata +2 -14
- data/doc/manual-html/chapter-1.html +0 -368
- data/doc/manual-html/chapter-2.html +0 -496
- data/doc/manual-html/chapter-3.html +0 -452
- data/doc/manual-html/chapter-4.html +0 -393
- data/doc/manual-html/chapter-5.html +0 -505
- data/doc/manual-html/chapter-6.html +0 -432
- data/doc/manual-html/chapter-7.html +0 -331
- data/doc/manual-html/index.html +0 -243
- data/doc/manual-html/stylesheets/manual.css +0 -265
- data/doc/manual-html/stylesheets/ruby.css +0 -17
data/doc/manual/manual.rb
CHANGED
@@ -13,7 +13,7 @@ require 'yaml'
|
|
13
13
|
require 'redcloth'
|
14
14
|
require 'syntax/convertors/html'
|
15
15
|
|
16
|
-
module
|
16
|
+
module Net ; module SSH
|
17
17
|
module Manual
|
18
18
|
|
19
19
|
class Manual
|
@@ -250,7 +250,7 @@ if __FILE__ == $0
|
|
250
250
|
FileUtils.mkdir_p File.join( output_path, "stylesheets" )
|
251
251
|
|
252
252
|
log_action "Loading manual.yml..."
|
253
|
-
manual =
|
253
|
+
manual = Net::SSH::Manual::Manual.load( 'manual.yml' )
|
254
254
|
|
255
255
|
# force these to be defined at the TOPLEVEL_BINDING
|
256
256
|
object = nil
|
@@ -1,7 +1,5 @@
|
|
1
1
|
Net::SSH is a pure-Ruby implementation of the SSH2 client protocol. It supports the following features:
|
2
2
|
|
3
3
|
* User authentication via explicit username/password, or using a public-key/private-key pair.
|
4
|
-
|
5
4
|
* Port forwarding, both from the local host to a remote computer via the remote host, and from the remote host to the local host.
|
6
|
-
|
7
5
|
* Execute processes on the remote machine, both interactively and non-interactively ("batch").
|
@@ -48,6 +48,12 @@ module Net
|
|
48
48
|
# The maximum data window size for this channel
|
49
49
|
attr_reader :window_size
|
50
50
|
|
51
|
+
# The maximum packet size that may be sent over this channel
|
52
|
+
attr_reader :local_maximum_packet_size
|
53
|
+
|
54
|
+
# The maximum data window size for this channel
|
55
|
+
attr_reader :local_window_size
|
56
|
+
|
51
57
|
#--
|
52
58
|
# ====================================================================
|
53
59
|
# FACTORY METHODS
|
@@ -66,7 +72,8 @@ module Net
|
|
66
72
|
msg.write_byte CHANNEL_OPEN
|
67
73
|
msg.write_string type
|
68
74
|
msg.write_long channel.local_id
|
69
|
-
msg.write_long
|
75
|
+
msg.write_long channel.local_window_size
|
76
|
+
msg.write_long channel.local_maximum_packet_size
|
70
77
|
msg.write data.to_s if data
|
71
78
|
|
72
79
|
connection.send_message msg
|
@@ -101,6 +108,8 @@ module Net
|
|
101
108
|
@buffers = buffers
|
102
109
|
@type = type
|
103
110
|
@local_id = @connection.allocate_channel_id
|
111
|
+
@local_window_size = 0x20000
|
112
|
+
@local_maximum_packet_size = 0x10000
|
104
113
|
end
|
105
114
|
|
106
115
|
#--
|
@@ -255,6 +264,17 @@ module Net
|
|
255
264
|
self
|
256
265
|
end
|
257
266
|
|
267
|
+
# Send a "window adjust" message to the server for this channel,
|
268
|
+
# informing it that it may send this many more bytes over the
|
269
|
+
# channel.
|
270
|
+
def send_window_adjust( size )
|
271
|
+
msg = @buffers.writer
|
272
|
+
msg.write_byte CHANNEL_WINDOW_ADJUST
|
273
|
+
msg.write_long @remote_id
|
274
|
+
msg.write_long size
|
275
|
+
@connection.send_message msg
|
276
|
+
end
|
277
|
+
|
258
278
|
# Send a data packet to the server, over the channel.
|
259
279
|
def send_data( data )
|
260
280
|
@connection.register_data_request( self, data )
|
@@ -422,11 +442,17 @@ module Net
|
|
422
442
|
|
423
443
|
# Invoked when the server sends a data packet. This in turn calls the
|
424
444
|
# "on_data" callback.
|
425
|
-
|
445
|
+
def do_data( data )
|
446
|
+
update_local_window_size data
|
447
|
+
callback :data, self, data
|
448
|
+
end
|
426
449
|
|
427
450
|
# Invoked when the server sends an extended data packet. This in turn
|
428
451
|
# calls the "on_extended_data" callback.
|
429
|
-
|
452
|
+
def do_extended_data( type, data )
|
453
|
+
update_local_window_size data
|
454
|
+
callback :extended_data, self, type, data
|
455
|
+
end
|
430
456
|
|
431
457
|
# Invoked when the server sends an EOF packet. This in turn calls the
|
432
458
|
# "on_eof" callback.
|
@@ -450,6 +476,19 @@ module Net
|
|
450
476
|
# ====================================================================
|
451
477
|
#++
|
452
478
|
|
479
|
+
# Updates the window size for this channel based on the size of the
|
480
|
+
# data that was receieved. If no more space in the window is left,
|
481
|
+
# a message is sent to the server indicating that the window size
|
482
|
+
# is increased.
|
483
|
+
def update_local_window_size( data )
|
484
|
+
@local_window_size -= data.length
|
485
|
+
if @local_window_size < 4096
|
486
|
+
@local_window_size += 0x20000
|
487
|
+
send_window_adjust 0x20000
|
488
|
+
end
|
489
|
+
end
|
490
|
+
private :update_local_window_size
|
491
|
+
|
453
492
|
# A convenience utility method for invoking a named callback with a
|
454
493
|
# set of arguments.
|
455
494
|
def callback( which, *args )
|
@@ -50,20 +50,17 @@ module Net
|
|
50
50
|
# Called to process the channel in a loop. It will repeatedly read
|
51
51
|
# from the client and send the results across the channel.
|
52
52
|
def process( channel )
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
break if data.nil? || data.length < 1
|
58
|
-
channel.send_data data
|
59
|
-
end
|
60
|
-
|
61
|
-
channel.close
|
62
|
-
rescue StandardError, Exception => e
|
63
|
-
@log.error "error processing connection: " +
|
64
|
-
"#{e.class} (#{e.message})\n " +
|
65
|
-
e.backtrace.join("\n ")
|
53
|
+
loop do
|
54
|
+
break if channel[:eof]
|
55
|
+
data = @client.recv(@block_size) or break
|
56
|
+
channel.send_data data unless data.empty?
|
66
57
|
end
|
58
|
+
|
59
|
+
channel.close
|
60
|
+
rescue StandardError, Exception => e
|
61
|
+
@log.error "error processing connection: " +
|
62
|
+
"#{e.class} (#{e.message})\n " +
|
63
|
+
e.backtrace.join("\n ")
|
67
64
|
end
|
68
65
|
|
69
66
|
end
|
@@ -44,9 +44,11 @@ module Net
|
|
44
44
|
begin
|
45
45
|
loop do
|
46
46
|
break if channel[:eof]
|
47
|
-
data =
|
48
|
-
|
49
|
-
|
47
|
+
data = ""
|
48
|
+
while IO.select([@client],nil,nil,0.01)
|
49
|
+
data << @client.recv(@block_size)
|
50
|
+
end
|
51
|
+
channel.send_data data unless data.empty?
|
50
52
|
end
|
51
53
|
rescue Exception => e
|
52
54
|
@log.error "error while forwarding remote port: " +
|
@@ -149,13 +149,8 @@ module Net
|
|
149
149
|
if @log.debug?
|
150
150
|
@log.debug "reading #{@cipher.block_size} bytes from socket..."
|
151
151
|
end
|
152
|
-
data = @socket.recv( @cipher.block_size )
|
153
152
|
|
154
|
-
|
155
|
-
if data.length < 1
|
156
|
-
raise Net::SSH::Transport::Disconnect,
|
157
|
-
"connection closed by remote host"
|
158
|
-
end
|
153
|
+
data = read( @cipher.block_size )
|
159
154
|
|
160
155
|
# decipher it
|
161
156
|
reader = @buffers.reader( @cipher.update( data ) )
|
@@ -169,11 +164,7 @@ module Net
|
|
169
164
|
end
|
170
165
|
|
171
166
|
# read the remainder of the packet and decrypt it.
|
172
|
-
data =
|
173
|
-
loop do
|
174
|
-
data << @socket.recv( remaining_to_read - data.length )
|
175
|
-
break if data.length >= remaining_to_read
|
176
|
-
end
|
167
|
+
data = read( remaining_to_read )
|
177
168
|
|
178
169
|
reader.append @cipher.update( data )
|
179
170
|
reader.append @cipher.final
|
@@ -203,6 +194,29 @@ module Net
|
|
203
194
|
end
|
204
195
|
end
|
205
196
|
|
197
|
+
def read( length )
|
198
|
+
if IO === @socket
|
199
|
+
data = ""
|
200
|
+
while data.length < length
|
201
|
+
break if @socket.closed?
|
202
|
+
if ( IO.select([@socket],nil,nil,0.01) rescue nil )
|
203
|
+
data << @socket.sysread(length-data.length)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
else
|
207
|
+
data = @socket.recv(length)
|
208
|
+
end
|
209
|
+
|
210
|
+
# if the data is less than expected, the socket was closed
|
211
|
+
if data.nil? || data.length < length
|
212
|
+
raise Net::SSH::Transport::Disconnect,
|
213
|
+
"connection closed by remote host"
|
214
|
+
end
|
215
|
+
|
216
|
+
data
|
217
|
+
end
|
218
|
+
private :read
|
219
|
+
|
206
220
|
end
|
207
221
|
|
208
222
|
end
|
@@ -103,7 +103,15 @@ module Net
|
|
103
103
|
@hostname =
|
104
104
|
Socket.getnameinfo( sockaddr, Socket::NI_NAMEREQD ).first
|
105
105
|
rescue
|
106
|
-
|
106
|
+
begin
|
107
|
+
@hostname = Socket.getnameinfo( sockaddr ).first
|
108
|
+
rescue
|
109
|
+
begin
|
110
|
+
@hostname = Socket.gethostbyname( Socket.gethostname ).first
|
111
|
+
rescue
|
112
|
+
@logger.error "the client ipaddr/name could not be determined"
|
113
|
+
end
|
114
|
+
end
|
107
115
|
end
|
108
116
|
|
109
117
|
return @hostname
|
@@ -124,7 +132,7 @@ module Net
|
|
124
132
|
# Closes the connection.
|
125
133
|
def close
|
126
134
|
# TODO: send a DISCONNECT message to the server to close gracefully
|
127
|
-
@socket.
|
135
|
+
@socket.close
|
128
136
|
end
|
129
137
|
|
130
138
|
def get_kex_byte_requirement
|
@@ -47,6 +47,7 @@ module Net
|
|
47
47
|
@methods = methods
|
48
48
|
@on_banner = proc { |msg,lang| puts msg }
|
49
49
|
@order = order.dup
|
50
|
+
@allowed_auth_methods = nil
|
50
51
|
end
|
51
52
|
|
52
53
|
# Causes the set of on-disk key files to be used to be set to the
|
@@ -104,6 +105,7 @@ module Net
|
|
104
105
|
|
105
106
|
when USERAUTH_FAILURE
|
106
107
|
authentications = buffer.read_string
|
108
|
+
@allowed_auth_methods = authentications.split(/,/)
|
107
109
|
partial_success = buffer.read_bool
|
108
110
|
return OpenStruct.new( :message_type => type,
|
109
111
|
:authentications => authentications,
|
@@ -151,6 +153,11 @@ module Net
|
|
151
153
|
:key_manager => @key_manager }
|
152
154
|
|
153
155
|
@order.each do |auth_method|
|
156
|
+
# if the server has reported a list of auth methods that are
|
157
|
+
# allowed to continue, only consider those auth methods.
|
158
|
+
next if @allowed_auth_methods &&
|
159
|
+
!@allowed_auth_methods.include?( auth_method )
|
160
|
+
|
154
161
|
@log.debug "trying #{auth_method.inspect}" if @log.debug?
|
155
162
|
|
156
163
|
impl = @methods[ auth_method.downcase.gsub(/-/,"_").intern ]
|
@@ -44,16 +44,21 @@ module Net
|
|
44
44
|
|
45
45
|
b.keyboard_interactive_callback do |c,p|
|
46
46
|
proc do |req|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
47
|
+
if req.password
|
48
|
+
[ req.password ] * req.prompts.length
|
49
|
+
else
|
50
|
+
responses = []
|
51
|
+
puts req.name unless req.name.empty?
|
52
|
+
puts req.instruction unless req.instruction.empty?
|
53
|
+
req.prompts.each do |prompt|
|
54
|
+
response = prompt.echo ?
|
55
|
+
gets.chomp :
|
56
|
+
c[:keyboard_interactive_prompter].
|
57
|
+
password( prompt.prompt )
|
58
|
+
responses << response
|
59
|
+
end
|
60
|
+
responses
|
55
61
|
end
|
56
|
-
responses
|
57
62
|
end
|
58
63
|
end
|
59
64
|
|
data/lib/net/ssh/version.rb
CHANGED
@@ -65,7 +65,7 @@ class TC_Channel < Test::Unit::TestCase
|
|
65
65
|
channel = Net::SSH::Connection::Channel.open( @connection, Log.new,
|
66
66
|
Buffers.new, "test" )
|
67
67
|
assert_equal [ :allocate_channel_id,
|
68
|
-
"\132\0\0\0\4test\0\0\4\xd2\
|
68
|
+
"\132\0\0\0\4test\0\0\4\xd2\x00\x02\x00\x00\x00\x01\x00\x00" ],
|
69
69
|
@connection.events
|
70
70
|
assert_equal "test", channel.type
|
71
71
|
end
|
@@ -74,7 +74,7 @@ class TC_Channel < Test::Unit::TestCase
|
|
74
74
|
channel = Net::SSH::Connection::Channel.open( @connection, Log.new,
|
75
75
|
Buffers.new, "test", "some data" )
|
76
76
|
assert_equal [ :allocate_channel_id,
|
77
|
-
"\132\0\0\0\4test\0\0\4\xd2\
|
77
|
+
"\132\0\0\0\4test\0\0\4\xd2\x00\x02\x00\x00\x00\x01\x00\x00some data" ],
|
78
78
|
@connection.events
|
79
79
|
assert_equal "test", channel.type
|
80
80
|
end
|
data/test/proxy/tc_http.rb
CHANGED
data/test/proxy/tc_socks4.rb
CHANGED
data/test/proxy/tc_socks5.rb
CHANGED
@@ -70,8 +70,11 @@ class TC_RemoteNetworkHandler < Test::Unit::TestCase
|
|
70
70
|
@thread = Thread.new {
|
71
71
|
server = TCPServer.new( HOST, PORT )
|
72
72
|
client = server.accept
|
73
|
-
|
74
|
-
|
73
|
+
until @script.empty?
|
74
|
+
client.send @script.shift, 0
|
75
|
+
sleep 0.1
|
76
|
+
end
|
77
|
+
server.shutdown rescue nil
|
75
78
|
}
|
76
79
|
end
|
77
80
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: net-ssh
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2005-
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2005-02-06
|
8
8
|
summary: Net::SSH is a pure-Ruby implementation of the SSH2 client protocol.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -28,21 +28,9 @@ authors:
|
|
28
28
|
- Jamis Buck
|
29
29
|
files:
|
30
30
|
- doc/LICENSE-RUBY
|
31
|
-
- doc/manual-html
|
32
31
|
- doc/LICENSE-BSD
|
33
32
|
- doc/LICENSE-GPL
|
34
33
|
- doc/manual
|
35
|
-
- doc/manual-html/stylesheets
|
36
|
-
- doc/manual-html/chapter-1.html
|
37
|
-
- doc/manual-html/chapter-2.html
|
38
|
-
- doc/manual-html/chapter-3.html
|
39
|
-
- doc/manual-html/chapter-4.html
|
40
|
-
- doc/manual-html/chapter-5.html
|
41
|
-
- doc/manual-html/chapter-6.html
|
42
|
-
- doc/manual-html/chapter-7.html
|
43
|
-
- doc/manual-html/index.html
|
44
|
-
- doc/manual-html/stylesheets/manual.css
|
45
|
-
- doc/manual-html/stylesheets/ruby.css
|
46
34
|
- doc/manual/manual.yml
|
47
35
|
- doc/manual/stylesheets
|
48
36
|
- doc/manual/tutorial.erb
|
@@ -1,368 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title>Net::SSH Manual :: Chapter 1: Introduction</title>
|
4
|
-
<link type="text/css" rel="stylesheet" href="stylesheets/manual.css" />
|
5
|
-
</head>
|
6
|
-
|
7
|
-
<body>
|
8
|
-
<div id="banner">
|
9
|
-
<table border='0' cellpadding='0' cellspacing='0' width='100%'>
|
10
|
-
<tr><td valign='top' align='left'>
|
11
|
-
<div class="title">
|
12
|
-
<span class="product">Net::SSH—</span><br />
|
13
|
-
<span class="tagline">Secure Shell for Ruby</span>
|
14
|
-
</div>
|
15
|
-
</td><td valign='middle' align='right'>
|
16
|
-
<div class="info">
|
17
|
-
Net::SSH Version: <strong>0.9.0</strong><br />
|
18
|
-
Manual Last Updated: <strong>2005-01-11 21:39 GMT</strong>
|
19
|
-
</div>
|
20
|
-
</td></tr>
|
21
|
-
</table>
|
22
|
-
</div>
|
23
|
-
|
24
|
-
<table border='0' width='100%' cellpadding='0' cellspacing='0'>
|
25
|
-
<tr><td valign='top'>
|
26
|
-
|
27
|
-
<div id="navigation">
|
28
|
-
<h1>Net::SSH Manual</h1>
|
29
|
-
|
30
|
-
<h2>Chapters</h2>
|
31
|
-
<ol type="I">
|
32
|
-
|
33
|
-
<li><strong>
|
34
|
-
<a href="chapter-1.html">
|
35
|
-
Introduction
|
36
|
-
</a>
|
37
|
-
</strong> <big>←</big>
|
38
|
-
<ol type="1">
|
39
|
-
|
40
|
-
<li><a href="chapter-1.html#s1">What is Net::SSH?</a></li>
|
41
|
-
|
42
|
-
<li><a href="chapter-1.html#s2">What isn’t Net::SSH?</a></li>
|
43
|
-
|
44
|
-
<li><a href="chapter-1.html#s3">Getting Net::SSH</a></li>
|
45
|
-
|
46
|
-
<li><a href="chapter-1.html#s4">License Information</a></li>
|
47
|
-
|
48
|
-
<li><a href="chapter-1.html#s5">Support</a></li>
|
49
|
-
|
50
|
-
<li><a href="chapter-1.html#s6">About the Author</a></li>
|
51
|
-
|
52
|
-
</ol>
|
53
|
-
</li>
|
54
|
-
|
55
|
-
<li>
|
56
|
-
<a href="chapter-2.html">
|
57
|
-
Starting a Session
|
58
|
-
</a>
|
59
|
-
|
60
|
-
<ol type="1">
|
61
|
-
|
62
|
-
<li><a href="chapter-2.html#s1">Using Net::SSH.start</a></li>
|
63
|
-
|
64
|
-
<li><a href="chapter-2.html#s2">Using a Public/Private Key</a></li>
|
65
|
-
|
66
|
-
<li><a href="chapter-2.html#s3">Options</a></li>
|
67
|
-
|
68
|
-
<li><a href="chapter-2.html#s4">Using Net::SSH::Session</a></li>
|
69
|
-
|
70
|
-
</ol>
|
71
|
-
</li>
|
72
|
-
|
73
|
-
<li>
|
74
|
-
<a href="chapter-3.html">
|
75
|
-
Channels
|
76
|
-
</a>
|
77
|
-
|
78
|
-
<ol type="1">
|
79
|
-
|
80
|
-
<li><a href="chapter-3.html#s1">What are Channels?</a></li>
|
81
|
-
|
82
|
-
<li><a href="chapter-3.html#s2">Session.loop</a></li>
|
83
|
-
|
84
|
-
<li><a href="chapter-3.html#s3">Channel Types</a></li>
|
85
|
-
|
86
|
-
<li><a href="chapter-3.html#s4">Opening a Channel</a></li>
|
87
|
-
|
88
|
-
<li><a href="chapter-3.html#s5">Callbacks</a></li>
|
89
|
-
|
90
|
-
<li><a href="chapter-3.html#s6">Channel Operations</a></li>
|
91
|
-
|
92
|
-
</ol>
|
93
|
-
</li>
|
94
|
-
|
95
|
-
<li>
|
96
|
-
<a href="chapter-4.html">
|
97
|
-
Executing Commands
|
98
|
-
</a>
|
99
|
-
|
100
|
-
<ol type="1">
|
101
|
-
|
102
|
-
<li><a href="chapter-4.html#s1">Using Channels</a></li>
|
103
|
-
|
104
|
-
<li><a href="chapter-4.html#s2">Using #process.open</a></li>
|
105
|
-
|
106
|
-
<li><a href="chapter-4.html#s3">Using #process.popen3</a></li>
|
107
|
-
|
108
|
-
</ol>
|
109
|
-
</li>
|
110
|
-
|
111
|
-
<li>
|
112
|
-
<a href="chapter-5.html">
|
113
|
-
User Shells
|
114
|
-
</a>
|
115
|
-
|
116
|
-
<ol type="1">
|
117
|
-
|
118
|
-
<li><a href="chapter-5.html#s1">Introduction</a></li>
|
119
|
-
|
120
|
-
<li><a href="chapter-5.html#s2">Using Channels</a></li>
|
121
|
-
|
122
|
-
<li><a href="chapter-5.html#s3">Shell Service</a></li>
|
123
|
-
|
124
|
-
<li><a href="chapter-5.html#s4">SyncShell Service</a></li>
|
125
|
-
|
126
|
-
<li><a href="chapter-5.html#s5">Terminal Clients</a></li>
|
127
|
-
|
128
|
-
</ol>
|
129
|
-
</li>
|
130
|
-
|
131
|
-
<li>
|
132
|
-
<a href="chapter-6.html">
|
133
|
-
Port Forwarding
|
134
|
-
</a>
|
135
|
-
|
136
|
-
<ol type="1">
|
137
|
-
|
138
|
-
<li><a href="chapter-6.html#s1">Introduction</a></li>
|
139
|
-
|
140
|
-
<li><a href="chapter-6.html#s2">Local-to-Remote</a></li>
|
141
|
-
|
142
|
-
<li><a href="chapter-6.html#s3">Remote-to-Local</a></li>
|
143
|
-
|
144
|
-
<li><a href="chapter-6.html#s4">Direct Channels</a></li>
|
145
|
-
|
146
|
-
<li><a href="chapter-6.html#s5">Remote-to-Local Handlers</a></li>
|
147
|
-
|
148
|
-
</ol>
|
149
|
-
</li>
|
150
|
-
|
151
|
-
<li>
|
152
|
-
<a href="chapter-7.html">
|
153
|
-
Using Proxies
|
154
|
-
</a>
|
155
|
-
|
156
|
-
<ol type="1">
|
157
|
-
|
158
|
-
<li><a href="chapter-7.html#s1">Introduction</a></li>
|
159
|
-
|
160
|
-
<li><a href="chapter-7.html#s2"><span class="caps">HTTP</span></a></li>
|
161
|
-
|
162
|
-
<li><a href="chapter-7.html#s3"><span class="caps">SOCKS</span></a></li>
|
163
|
-
|
164
|
-
</ol>
|
165
|
-
</li>
|
166
|
-
|
167
|
-
</ol>
|
168
|
-
|
169
|
-
<h2>Other Documentation</h2>
|
170
|
-
|
171
|
-
<ul>
|
172
|
-
<li><a href="http://net-ssh.rubyforge.org/api/index.html">Net::SSH API</a></li>
|
173
|
-
<li><a href="http://rubyforge.org/tracker/?atid=1842&group_id=274&func=browse">Net::SSH FAQ</a></li>
|
174
|
-
</ul>
|
175
|
-
|
176
|
-
<h2>Tutorials</h2>
|
177
|
-
<ol>
|
178
|
-
|
179
|
-
</ol>
|
180
|
-
|
181
|
-
<p align="center"><strong>More To Come...</strong></p>
|
182
|
-
|
183
|
-
<div class="license">
|
184
|
-
<a href="http://creativecommons.org/licenses/by-sa/2.0/"><img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights" /></a><br />
|
185
|
-
This manual is licensed under a <a href="http://creativecommons.org/licenses/by-sa/2.0/">Creative Commons License</a>.
|
186
|
-
</div>
|
187
|
-
</div>
|
188
|
-
|
189
|
-
</td><td valign='top' width="100%">
|
190
|
-
|
191
|
-
<div id="content">
|
192
|
-
|
193
|
-
<div class="top"><div class="prevnext">
|
194
|
-
|
195
|
-
<a href="index.html">Up</a>
|
196
|
-
|
197
|
-
| <a href="chapter-2.html">Next (2. Starting a Session)</a>
|
198
|
-
|
199
|
-
</div></div>
|
200
|
-
|
201
|
-
<h1>1. Introduction</h1>
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
<h2>
|
206
|
-
<a name="s1"></a>
|
207
|
-
1.1. What is Net::SSH?
|
208
|
-
</h2>
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
<div class="section">
|
213
|
-
<p>Net::SSH is a pure-Ruby implementation of the <span class="caps">SSH2</span> client protocol. It supports the following features:</p>
|
214
|
-
<ul>
|
215
|
-
<li>User authentication via explicit username/password, or using a public-key/private-key pair.
|
216
|
-
</li>
|
217
|
-
<li>Port forwarding, both from the local host to a remote computer via the remote host, and from the remote host to the local host.
|
218
|
-
</li>
|
219
|
-
<li>Execute processes on the remote machine, both interactively and non-interactively (“batch”).</li>
|
220
|
-
</ul>
|
221
|
-
</div>
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
<h2>
|
226
|
-
<a name="s2"></a>
|
227
|
-
1.2. What isn’t Net::SSH?
|
228
|
-
</h2>
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
<div class="section">
|
233
|
-
<p>Net::SSH is only a <em>client</em> implementation, not a server. Given sufficient motivation and encouragement from the community, perhaps it will someday include an <span class="caps">SSH</span> server, but as of right now, it does not.</p>
|
234
|
-
|
235
|
-
<p>Furthermore, it is only an <em><span class="caps">SSH2</span></em> client. This means that it cannot connect to <span class="caps">SSH</span> servers that only understand the older <span class="caps">SSH1</span> protocol.</p>
|
236
|
-
</div>
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
<h2>
|
241
|
-
<a name="s3"></a>
|
242
|
-
1.3. Getting Net::SSH
|
243
|
-
</h2>
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
<div class="section">
|
248
|
-
<h3>Prerequisites:</h3>
|
249
|
-
|
250
|
-
<p>In order to use Net::SSH, you must be using a supported version of Ruby’s OpenSSL module. The version distributed with Ruby 1.8.1 and earlier is not sufficient, and is lacking several features that Net::SSH relies on. If you are using Ruby 1.8.1 (or earlier), you should either upgrade to 1.8.2, or download and install an updated version of the OpenSSL module. You can download a usable snapshot from the <a href="http://rubyforge.org/projects/net-ssh">Net::SSH downloads page</a>.</p>
|
251
|
-
|
252
|
-
<p>Furthermore, you must make sure that Ruby’s OpenSSL module has been compiled against <em>at least</em> version 0.9.7 of the OpenSSL library. Prior versions lacked functionality that Net::SSH depends on (notably, the ‘padding’ property of ciphers).</p>
|
253
|
-
|
254
|
-
<p>Optionally, you can install the <a href="http://raa.ruby-lang.org/project/ruby-termios">ruby-termios</a> and <a href="http://raa.ruby-lang.org/project/ruby-password">ruby-password</a> modules. If you do, then the ruby-password module will be used when prompting you for the passphrases needed to load your keys (if your keys have passphrases).</p>
|
255
|
-
|
256
|
-
<h3>Using <a href="http://rubygems.rubyforge.org">RubyGems</a></h3>
|
257
|
-
|
258
|
-
<p>If you have <a href="http://rubygems.rubyforge.org">RubyGems</a> installed, installing Net::SSH is simple:</p>
|
259
|
-
|
260
|
-
<div class='figure'>
|
261
|
-
<span class='caption'>Using Rubygems to install Net::SSH [shell]</span>
|
262
|
-
<div class='body'><link rel='stylesheet' type='text/css' href='stylesheets/shell.css' /><div class='shell'><pre>gem install net-ssh</pre></div></div></div>
|
263
|
-
|
264
|
-
<p>You still need to make sure you have a working version of Ruby’s OpenSSL module, but other than that, you should be good to go!</p>
|
265
|
-
|
266
|
-
<h3>Using <a href="http://rpa-base.rubyforge.org">rpa-base</a></h3>
|
267
|
-
|
268
|
-
<p>If you have <a href="http://rpa-base.rubyforge.org">rpa-base</a> installed:</p>
|
269
|
-
|
270
|
-
<div class='figure'>
|
271
|
-
<span class='caption'>Using RPA to install Net::SSH [shell]</span>
|
272
|
-
<div class='body'><link rel='stylesheet' type='text/css' href='stylesheets/shell.css' /><div class='shell'><pre>rpa install net-ssh</pre></div></div></div>
|
273
|
-
|
274
|
-
<p>As with the gem install, you still need to make sure you have a working version of Ruby’s OpenSSL module, but other than that, you should be good to go!</p>
|
275
|
-
|
276
|
-
<h3>Doing it the hard way</h3>
|
277
|
-
|
278
|
-
<p>If you don’t have <a href="http://rubygems.rubyforge.org">RubyGems</a> or <a href="http://rpa-base.rubyforge.org">rpa-base</a>, or if you just prefer to install things by hand, you can always go to the <a href="http://rubyforge.org/projects/net-ssh">Net::SSH downloads page</a> and grab the package of your choice: <code>tar.gz</code>, <code>tar.bz2</code>, or <code>zip</code>.</p>
|
279
|
-
|
280
|
-
<p>Then, unpack the archive and run the <code>setup.rb</code> script:</p>
|
281
|
-
|
282
|
-
<div class='figure'>
|
283
|
-
<span class='caption'>Using setup.rb to install Net::SSH [shell]</span>
|
284
|
-
<div class='body'><link rel='stylesheet' type='text/css' href='stylesheets/shell.css' /><div class='shell'><pre>ruby setup.rb config
|
285
|
-
ruby setup.rb setup
|
286
|
-
ruby setup.rb install</pre></div></div></div>
|
287
|
-
</div>
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
<h2>
|
292
|
-
<a name="s4"></a>
|
293
|
-
1.4. License Information
|
294
|
-
</h2>
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
<div class="section">
|
299
|
-
<p>Net::SSH is made available under either the <span class="caps">BSD</span> license, or the same license Ruby (which, by extension, also allows the <span class="caps">GPL</span> as a permissable license as well). You can view the full text of any of these licenses in the <code>doc</code> subdirectory of the Net::SSH distrubtion. The texts of the <span class="caps">BSD</span> and <span class="caps">GPL</span> licenses are also available online: <a href="http://www.opensource.org/licenses/bsd-license.php">BSD</a> and <a href="http://www.opensource.org/licenses/gpl-license.php">GPL</a>.</p>
|
300
|
-
|
301
|
-
<p>This manual (in any form, be it source or otherwise) and the scripts and templates used to generate it, are all distributed under the <a href="http://creativecommons.org">Creative Commons</a> <a href="http://creativecommons.org/licenses/by-sa/2.0">Attribution-ShareAlike</a> license.</p>
|
302
|
-
|
303
|
-
<p>If you desire permission to use either Net::SSH or the manual in a manner incompatible with these licenses, please contact the copyright holder (<a href="mailto:jgb3@email.byu.edu">Jamis Buck</a>) in order to negotiate a more compatible license.</p>
|
304
|
-
</div>
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
<h2>
|
309
|
-
<a name="s5"></a>
|
310
|
-
1.5. Support
|
311
|
-
</h2>
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
<div class="section">
|
316
|
-
<p>Mailing lists, bug trackers, feature requests, and public forums are all available (courtesty of <a href="http://rubyforge.org">RubyForge</a>) at the <a href="http://rubyforge.org/projects/net-ssh">Net::SSH project page</a>.</p>
|
317
|
-
|
318
|
-
<h3>Mailing Lists</h3>
|
319
|
-
|
320
|
-
<table>
|
321
|
-
<tr>
|
322
|
-
<th><strong>List Name</strong> </th>
|
323
|
-
<th>—</th>
|
324
|
-
<th><strong>Description</strong> </th>
|
325
|
-
</tr>
|
326
|
-
<tr>
|
327
|
-
<td style="vertical-align:top;text-align:center;"><a href="http://rubyforge.org/pipermail/net-ssh-users">net-ssh-users</a></td>
|
328
|
-
<td style="vertical-align:top;text-align:center;"><a href="http://rubyforge.org/mailman/listinfo/net-ssh-users">subscribe / unsubscribe</a></td>
|
329
|
-
<td> The Net::SSH users list is devoted to the discussion of and questions about the usage of the Net::SSH module. If you can’t quite figure out how to get a feature of Net::SSH to work, this is the list you would go to in order to ask your questions.</td>
|
330
|
-
</tr>
|
331
|
-
<tr>
|
332
|
-
<td style="vertical-align:top;text-align:center;"><a href="http://rubyforge.org/pipermail/net-ssh-devel">net-ssh-devel</a></td>
|
333
|
-
<td style="vertical-align:top;text-align:center;"><a href="http://rubyforge.org/mailman/listinfo/net-ssh-devel">subscribe / unsubscribe</a></td>
|
334
|
-
<td> The Net::SSH developers list is devoted to the discussion of Net::SSH’s implementation. If you have created a patch that you would like to discuss, or if you would like to discuss a new feature, this is the list for you.</td>
|
335
|
-
</tr>
|
336
|
-
</table>
|
337
|
-
</div>
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
<h2>
|
342
|
-
<a name="s6"></a>
|
343
|
-
1.6. About the Author
|
344
|
-
</h2>
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
<div class="section">
|
349
|
-
<p>Net::SSH was written by <a href="mailto:jgb3@email.byu.edu">Jamis Buck</a>. Feel free to send him compliments, candy, money, praise, or new feature patches—he likes all those things. You can send him questions and suggestions, too, if you really want to. However, for bug reports and general feature requests, please use the trackers on the <a href="http://rubyforge.org/projects/net-ssh">Net::SSH project page</a>.</p>
|
350
|
-
</div>
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
<div class="bottom"><div class="prevnext">
|
355
|
-
|
356
|
-
<a href="index.html">Up</a>
|
357
|
-
|
358
|
-
| <a href="chapter-2.html">Next (2. Starting a Session)</a>
|
359
|
-
|
360
|
-
</div></div>
|
361
|
-
|
362
|
-
|
363
|
-
</div>
|
364
|
-
|
365
|
-
</td></tr>
|
366
|
-
</table>
|
367
|
-
</body>
|
368
|
-
</html>
|