net-ssh 1.1.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +37 -0
- data/Manifest +101 -0
- data/README.rdoc +110 -0
- data/Rakefile +26 -0
- data/{THANKS → THANKS.rdoc} +2 -5
- data/lib/net/ssh.rb +189 -57
- data/lib/net/ssh/authentication/agent.rb +175 -0
- data/lib/net/ssh/authentication/constants.rb +18 -0
- data/lib/net/ssh/authentication/key_manager.rb +166 -0
- data/lib/net/ssh/authentication/methods/abstract.rb +60 -0
- data/lib/net/ssh/authentication/methods/hostbased.rb +71 -0
- data/lib/net/ssh/authentication/methods/keyboard_interactive.rb +66 -0
- data/lib/net/ssh/authentication/methods/password.rb +39 -0
- data/lib/net/ssh/authentication/methods/publickey.rb +92 -0
- data/lib/net/ssh/authentication/pageant.rb +176 -0
- data/lib/net/ssh/authentication/session.rb +116 -0
- data/lib/net/ssh/buffer.rb +339 -0
- data/lib/net/ssh/buffered_io.rb +149 -0
- data/lib/net/ssh/config.rb +173 -0
- data/lib/net/ssh/connection/channel.rb +575 -454
- data/lib/net/ssh/connection/constants.rb +31 -45
- data/lib/net/ssh/connection/session.rb +569 -0
- data/lib/net/ssh/connection/term.rb +176 -88
- data/lib/net/ssh/errors.rb +83 -61
- data/lib/net/ssh/key_factory.rb +85 -0
- data/lib/net/ssh/known_hosts.rb +129 -0
- data/lib/net/ssh/loggable.rb +61 -0
- data/lib/net/ssh/packet.rb +102 -0
- data/lib/net/ssh/prompt.rb +93 -0
- data/lib/net/ssh/proxy/errors.rb +8 -28
- data/lib/net/ssh/proxy/http.rb +75 -107
- data/lib/net/ssh/proxy/socks4.rb +35 -48
- data/lib/net/ssh/proxy/socks5.rb +76 -108
- data/lib/net/ssh/service/forward.rb +267 -0
- data/lib/net/ssh/test.rb +89 -0
- data/lib/net/ssh/test/channel.rb +129 -0
- data/lib/net/ssh/test/extensions.rb +152 -0
- data/lib/net/ssh/test/kex.rb +44 -0
- data/lib/net/ssh/test/local_packet.rb +51 -0
- data/lib/net/ssh/test/packet.rb +81 -0
- data/lib/net/ssh/test/remote_packet.rb +38 -0
- data/lib/net/ssh/test/script.rb +157 -0
- data/lib/net/ssh/test/socket.rb +59 -0
- data/lib/net/ssh/transport/algorithms.rb +384 -0
- data/lib/net/ssh/transport/cipher_factory.rb +72 -0
- data/lib/net/ssh/transport/constants.rb +22 -58
- data/lib/net/ssh/transport/hmac.rb +31 -0
- data/lib/net/ssh/transport/hmac/abstract.rb +48 -0
- data/lib/net/ssh/transport/hmac/md5.rb +12 -0
- data/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
- data/lib/net/ssh/transport/hmac/none.rb +15 -0
- data/lib/net/ssh/transport/hmac/sha1.rb +13 -0
- data/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
- data/lib/net/ssh/transport/identity_cipher.rb +40 -0
- data/lib/net/ssh/transport/kex.rb +13 -0
- data/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +208 -0
- data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +77 -0
- data/lib/net/ssh/{util → transport}/openssl.rb +22 -40
- data/lib/net/ssh/transport/packet_stream.rb +230 -0
- data/lib/net/ssh/transport/server_version.rb +61 -0
- data/lib/net/ssh/transport/session.rb +225 -303
- data/lib/net/ssh/transport/state.rb +170 -0
- data/lib/net/ssh/verifiers/lenient.rb +30 -0
- data/lib/net/ssh/verifiers/null.rb +12 -0
- data/lib/net/ssh/verifiers/strict.rb +53 -0
- data/lib/net/ssh/version.rb +57 -26
- data/net-ssh.gemspec +54 -0
- data/setup.rb +1585 -0
- data/test/authentication/methods/common.rb +28 -0
- data/test/authentication/methods/test_abstract.rb +51 -0
- data/test/authentication/methods/test_hostbased.rb +108 -0
- data/test/authentication/methods/test_keyboard_interactive.rb +98 -0
- data/test/authentication/methods/test_password.rb +50 -0
- data/test/authentication/methods/test_publickey.rb +123 -0
- data/test/authentication/test_agent.rb +205 -0
- data/test/authentication/test_key_manager.rb +100 -0
- data/test/authentication/test_session.rb +93 -0
- data/test/common.rb +106 -0
- data/test/configs/exact_match +8 -0
- data/test/configs/wild_cards +14 -0
- data/test/connection/test_channel.rb +452 -0
- data/test/connection/test_session.rb +483 -0
- data/test/test_all.rb +6 -0
- data/test/test_buffer.rb +336 -0
- data/test/test_buffered_io.rb +63 -0
- data/test/test_config.rb +78 -0
- data/test/test_key_factory.rb +67 -0
- data/test/transport/hmac/test_md5.rb +34 -0
- data/test/transport/hmac/test_md5_96.rb +25 -0
- data/test/transport/hmac/test_none.rb +34 -0
- data/test/transport/hmac/test_sha1.rb +34 -0
- data/test/transport/hmac/test_sha1_96.rb +25 -0
- data/test/transport/kex/test_diffie_hellman_group1_sha1.rb +146 -0
- data/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +92 -0
- data/test/transport/test_algorithms.rb +302 -0
- data/test/transport/test_cipher_factory.rb +163 -0
- data/test/transport/test_hmac.rb +34 -0
- data/test/transport/test_identity_cipher.rb +40 -0
- data/test/transport/test_packet_stream.rb +433 -0
- data/test/transport/test_server_version.rb +55 -0
- data/test/transport/test_session.rb +312 -0
- data/test/transport/test_state.rb +173 -0
- metadata +102 -253
- data/ChangeLog +0 -560
- data/LICENSE +0 -7
- data/NEWS +0 -152
- data/README +0 -14
- data/bin/rb-keygen +0 -210
- data/doc/LICENSE-BSD +0 -27
- data/doc/LICENSE-GPL +0 -280
- data/doc/LICENSE-RUBY +0 -56
- data/doc/manual-html/chapter-1.html +0 -388
- data/doc/manual-html/chapter-2.html +0 -552
- data/doc/manual-html/chapter-3.html +0 -470
- data/doc/manual-html/chapter-4.html +0 -413
- data/doc/manual-html/chapter-5.html +0 -525
- data/doc/manual-html/chapter-6.html +0 -456
- data/doc/manual-html/chapter-7.html +0 -343
- data/doc/manual-html/index.html +0 -235
- data/doc/manual-html/stylesheets/manual.css +0 -270
- data/doc/manual-html/stylesheets/ruby.css +0 -17
- data/doc/manual/chapter.erb +0 -38
- data/doc/manual/example.erb +0 -18
- data/doc/manual/index.erb +0 -29
- data/doc/manual/manual.rb +0 -311
- data/doc/manual/manual.yml +0 -73
- data/doc/manual/page.erb +0 -87
- data/doc/manual/parts/0000.txt +0 -5
- data/doc/manual/parts/0001.txt +0 -3
- data/doc/manual/parts/0002.txt +0 -40
- data/doc/manual/parts/0003.txt +0 -6
- data/doc/manual/parts/0004.txt +0 -7
- data/doc/manual/parts/0005.txt +0 -1
- data/doc/manual/parts/0006.txt +0 -49
- data/doc/manual/parts/0007.txt +0 -67
- data/doc/manual/parts/0008.txt +0 -43
- data/doc/manual/parts/0009.txt +0 -14
- data/doc/manual/parts/0010.txt +0 -7
- data/doc/manual/parts/0011.txt +0 -14
- data/doc/manual/parts/0012.txt +0 -3
- data/doc/manual/parts/0013.txt +0 -20
- data/doc/manual/parts/0014.txt +0 -32
- data/doc/manual/parts/0015.txt +0 -14
- data/doc/manual/parts/0016.txt +0 -28
- data/doc/manual/parts/0017.txt +0 -50
- data/doc/manual/parts/0018.txt +0 -35
- data/doc/manual/parts/0019.txt +0 -7
- data/doc/manual/parts/0020.txt +0 -72
- data/doc/manual/parts/0021.txt +0 -50
- data/doc/manual/parts/0022.txt +0 -42
- data/doc/manual/parts/0023.txt +0 -51
- data/doc/manual/parts/0024.txt +0 -18
- data/doc/manual/parts/0025.txt +0 -18
- data/doc/manual/parts/0026.txt +0 -15
- data/doc/manual/parts/0027.txt +0 -37
- data/doc/manual/parts/0028.txt +0 -16
- data/doc/manual/parts/0029.txt +0 -1
- data/doc/manual/parts/0030.txt +0 -52
- data/doc/manual/parts/0031.txt +0 -25
- data/doc/manual/stylesheets/manual.css +0 -270
- data/doc/manual/stylesheets/ruby.css +0 -17
- data/doc/manual/tutorial.erb +0 -30
- data/examples/auth-forward.rb +0 -41
- data/examples/channel-demo.rb +0 -81
- data/examples/port-forward.rb +0 -51
- data/examples/process-demo.rb +0 -91
- data/examples/remote-net-port-forward.rb +0 -45
- data/examples/remote-port-forward.rb +0 -80
- data/examples/shell-demo.rb +0 -46
- data/examples/ssh-client.rb +0 -67
- data/examples/sync-shell-demo.rb +0 -69
- data/examples/tail-demo.rb +0 -49
- data/lib/net/ssh/connection/driver.rb +0 -446
- data/lib/net/ssh/connection/services.rb +0 -72
- data/lib/net/ssh/host-key-verifier.rb +0 -52
- data/lib/net/ssh/known-hosts.rb +0 -96
- data/lib/net/ssh/lenient-host-key-verifier.rb +0 -25
- data/lib/net/ssh/null-host-key-verifier.rb +0 -14
- data/lib/net/ssh/service/agentforward/driver.rb +0 -78
- data/lib/net/ssh/service/agentforward/services.rb +0 -41
- data/lib/net/ssh/service/forward/driver.rb +0 -319
- data/lib/net/ssh/service/forward/local-network-handler.rb +0 -71
- data/lib/net/ssh/service/forward/remote-network-handler.rb +0 -83
- data/lib/net/ssh/service/forward/services.rb +0 -76
- data/lib/net/ssh/service/process/driver.rb +0 -153
- data/lib/net/ssh/service/process/open.rb +0 -193
- data/lib/net/ssh/service/process/popen3.rb +0 -178
- data/lib/net/ssh/service/process/services.rb +0 -66
- data/lib/net/ssh/service/services.rb +0 -60
- data/lib/net/ssh/service/shell/driver.rb +0 -86
- data/lib/net/ssh/service/shell/services.rb +0 -54
- data/lib/net/ssh/service/shell/shell.rb +0 -222
- data/lib/net/ssh/service/shell/sync.rb +0 -114
- data/lib/net/ssh/session.rb +0 -305
- data/lib/net/ssh/transport/algorithm-negotiator.rb +0 -275
- data/lib/net/ssh/transport/compress/compressor.rb +0 -53
- data/lib/net/ssh/transport/compress/decompressor.rb +0 -53
- data/lib/net/ssh/transport/compress/none-compressor.rb +0 -39
- data/lib/net/ssh/transport/compress/none-decompressor.rb +0 -39
- data/lib/net/ssh/transport/compress/services.rb +0 -68
- data/lib/net/ssh/transport/compress/zlib-compressor.rb +0 -60
- data/lib/net/ssh/transport/compress/zlib-decompressor.rb +0 -52
- data/lib/net/ssh/transport/errors.rb +0 -47
- data/lib/net/ssh/transport/identity-cipher.rb +0 -61
- data/lib/net/ssh/transport/kex/dh-gex.rb +0 -106
- data/lib/net/ssh/transport/kex/dh.rb +0 -249
- data/lib/net/ssh/transport/kex/services.rb +0 -62
- data/lib/net/ssh/transport/ossl/buffer-factory.rb +0 -52
- data/lib/net/ssh/transport/ossl/buffer.rb +0 -87
- data/lib/net/ssh/transport/ossl/cipher-factory.rb +0 -98
- data/lib/net/ssh/transport/ossl/digest-factory.rb +0 -51
- data/lib/net/ssh/transport/ossl/hmac-factory.rb +0 -71
- data/lib/net/ssh/transport/ossl/hmac/hmac.rb +0 -62
- data/lib/net/ssh/transport/ossl/hmac/md5-96.rb +0 -44
- data/lib/net/ssh/transport/ossl/hmac/md5.rb +0 -46
- data/lib/net/ssh/transport/ossl/hmac/none.rb +0 -46
- data/lib/net/ssh/transport/ossl/hmac/services.rb +0 -68
- data/lib/net/ssh/transport/ossl/hmac/sha1-96.rb +0 -44
- data/lib/net/ssh/transport/ossl/hmac/sha1.rb +0 -45
- data/lib/net/ssh/transport/ossl/key-factory.rb +0 -116
- data/lib/net/ssh/transport/ossl/services.rb +0 -149
- data/lib/net/ssh/transport/packet-stream.rb +0 -236
- data/lib/net/ssh/transport/services.rb +0 -146
- data/lib/net/ssh/transport/version-negotiator.rb +0 -73
- data/lib/net/ssh/userauth/agent.rb +0 -222
- data/lib/net/ssh/userauth/constants.rb +0 -35
- data/lib/net/ssh/userauth/driver.rb +0 -183
- data/lib/net/ssh/userauth/methods/hostbased.rb +0 -119
- data/lib/net/ssh/userauth/methods/keyboard-interactive.rb +0 -104
- data/lib/net/ssh/userauth/methods/password.rb +0 -70
- data/lib/net/ssh/userauth/methods/publickey.rb +0 -137
- data/lib/net/ssh/userauth/methods/services.rb +0 -90
- data/lib/net/ssh/userauth/pageant.rb +0 -197
- data/lib/net/ssh/userauth/services.rb +0 -141
- data/lib/net/ssh/userauth/userkeys.rb +0 -258
- data/lib/net/ssh/util/buffer.rb +0 -274
- data/lib/net/ssh/util/prompter.rb +0 -73
- data/test/ALL-TESTS.rb +0 -18
- data/test/connection/tc_channel.rb +0 -136
- data/test/connection/tc_driver.rb +0 -287
- data/test/connection/tc_integration.rb +0 -87
- data/test/proxy/tc_http.rb +0 -209
- data/test/proxy/tc_socks4.rb +0 -148
- data/test/proxy/tc_socks5.rb +0 -214
- data/test/service/agentforward/tc_driver.rb +0 -138
- data/test/service/forward/tc_driver.rb +0 -289
- data/test/service/forward/tc_local_network_handler.rb +0 -123
- data/test/service/forward/tc_remote_network_handler.rb +0 -111
- data/test/service/process/tc_driver.rb +0 -79
- data/test/service/process/tc_integration.rb +0 -119
- data/test/service/process/tc_open.rb +0 -179
- data/test/service/process/tc_popen3.rb +0 -164
- data/test/tc_integration.rb +0 -80
- data/test/transport/compress/tc_none_compress.rb +0 -41
- data/test/transport/compress/tc_none_decompress.rb +0 -45
- data/test/transport/compress/tc_zlib_compress.rb +0 -61
- data/test/transport/compress/tc_zlib_decompress.rb +0 -48
- data/test/transport/kex/tc_dh.rb +0 -312
- data/test/transport/kex/tc_dh_gex.rb +0 -71
- data/test/transport/ossl/fixtures/dsa-encrypted +0 -15
- data/test/transport/ossl/fixtures/dsa-encrypted-bad +0 -15
- data/test/transport/ossl/fixtures/dsa-unencrypted +0 -12
- data/test/transport/ossl/fixtures/dsa-unencrypted-bad +0 -12
- data/test/transport/ossl/fixtures/dsa-unencrypted.pub +0 -1
- data/test/transport/ossl/fixtures/not-a-private-key +0 -4
- data/test/transport/ossl/fixtures/not-supported +0 -2
- data/test/transport/ossl/fixtures/rsa-encrypted +0 -18
- data/test/transport/ossl/fixtures/rsa-encrypted-bad +0 -18
- data/test/transport/ossl/fixtures/rsa-unencrypted +0 -15
- data/test/transport/ossl/fixtures/rsa-unencrypted-bad +0 -15
- data/test/transport/ossl/fixtures/rsa-unencrypted.pub +0 -1
- data/test/transport/ossl/hmac/tc_hmac.rb +0 -58
- data/test/transport/ossl/hmac/tc_md5.rb +0 -50
- data/test/transport/ossl/hmac/tc_md5_96.rb +0 -50
- data/test/transport/ossl/hmac/tc_none.rb +0 -50
- data/test/transport/ossl/hmac/tc_sha1.rb +0 -50
- data/test/transport/ossl/hmac/tc_sha1_96.rb +0 -50
- data/test/transport/ossl/tc_buffer.rb +0 -97
- data/test/transport/ossl/tc_buffer_factory.rb +0 -67
- data/test/transport/ossl/tc_cipher_factory.rb +0 -84
- data/test/transport/ossl/tc_digest_factory.rb +0 -39
- data/test/transport/ossl/tc_hmac_factory.rb +0 -72
- data/test/transport/ossl/tc_key_factory.rb +0 -199
- data/test/transport/tc_algorithm_negotiator.rb +0 -170
- data/test/transport/tc_identity_cipher.rb +0 -52
- data/test/transport/tc_integration.rb +0 -115
- data/test/transport/tc_packet_stream.rb +0 -184
- data/test/transport/tc_session.rb +0 -296
- data/test/transport/tc_version_negotiator.rb +0 -86
- data/test/userauth/methods/tc_hostbased.rb +0 -136
- data/test/userauth/methods/tc_password.rb +0 -89
- data/test/userauth/methods/tc_publickey.rb +0 -167
- data/test/userauth/tc_agent.rb +0 -223
- data/test/userauth/tc_driver.rb +0 -190
- data/test/userauth/tc_integration.rb +0 -97
- data/test/userauth/tc_userkeys.rb +0 -265
- data/test/util/tc_buffer.rb +0 -217
data/doc/manual/manual.yml
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
--- !jamisbuck.org,2004/^manual
|
2
|
-
|
3
|
-
# This content is made available under the Attribution-ShareAlike 2.0
|
4
|
-
# license from the Create Commons:
|
5
|
-
#
|
6
|
-
# http://creativecommons.org/licenses/by-sa/2.0/
|
7
|
-
|
8
|
-
meta: !^meta
|
9
|
-
copyright: 2004-2007
|
10
|
-
author: Jamis Buck
|
11
|
-
email: jamis@jamisbuck.org
|
12
|
-
|
13
|
-
product: !^product
|
14
|
-
name: Net::SSH
|
15
|
-
tagline: Secure Shell for Ruby
|
16
|
-
version: !!eval require "../../lib/net/ssh/version"; Net::SSH::Version::STRING
|
17
|
-
#logo: net-ssh.png
|
18
|
-
urls:
|
19
|
-
- Project Page: http://rubyforge.org/projects/net-ssh
|
20
|
-
- User Manual: http://net-ssh.rubyforge.org
|
21
|
-
- API Documentation: http://net-ssh.rubyforge.org/api
|
22
|
-
|
23
|
-
recent_updates:
|
24
|
-
- "Added information on ssh-agent forwarding."
|
25
|
-
- "Added information about the :paranoid setting."
|
26
|
-
|
27
|
-
chapters:
|
28
|
-
|
29
|
-
- "Introduction":
|
30
|
-
- "What is Net::SSH?": !!file parts/0000.txt
|
31
|
-
- "What isn't Net::SSH?": !!file parts/0001.txt
|
32
|
-
- "Getting Net::SSH": !!file parts/0002.txt
|
33
|
-
- "License Information": !!file parts/0003.txt
|
34
|
-
- "Support": !!file parts/0004.txt
|
35
|
-
- "About the Author": !!file parts/0005.txt
|
36
|
-
|
37
|
-
- "Starting a Session":
|
38
|
-
- "Using Net::SSH.start": !!file parts/0006.txt
|
39
|
-
- "Using a Public/Private Key": !!file parts/0007.txt
|
40
|
-
- "Options": !!file parts/0008.txt
|
41
|
-
- "Using Net::SSH::Session": !!file parts/0009.txt
|
42
|
-
|
43
|
-
- "Channels":
|
44
|
-
- "What are Channels?": !!file parts/0010.txt
|
45
|
-
- "Session.loop": !!file parts/0011.txt
|
46
|
-
- "Channel Types": !!file parts/0012.txt
|
47
|
-
- "Opening a Channel": !!file parts/0013.txt
|
48
|
-
- "Callbacks": !!file parts/0014.txt
|
49
|
-
- "Channel Operations": !!file parts/0015.txt
|
50
|
-
|
51
|
-
- "Executing Commands":
|
52
|
-
- "Using Channels": !!file parts/0016.txt
|
53
|
-
- "Using #process.open": !!file parts/0017.txt
|
54
|
-
- "Using #process.popen3": !!file parts/0018.txt
|
55
|
-
|
56
|
-
- "User Shells":
|
57
|
-
- "Introduction": !!file parts/0019.txt
|
58
|
-
- "Using Channels": !!file parts/0020.txt
|
59
|
-
- "Shell Service": !!file parts/0021.txt
|
60
|
-
- "SyncShell Service": !!file parts/0022.txt
|
61
|
-
- "Terminal Clients": !!file parts/0023.txt
|
62
|
-
|
63
|
-
- "Port Forwarding":
|
64
|
-
- "Introduction": !!file parts/0024.txt
|
65
|
-
- "Local-to-Remote": !!file parts/0025.txt
|
66
|
-
- "Remote-to-Local": !!file parts/0026.txt
|
67
|
-
- "Direct Channels": !!file parts/0027.txt
|
68
|
-
- "Remote-to-Local Handlers": !!file parts/0028.txt
|
69
|
-
|
70
|
-
- "Using Proxies":
|
71
|
-
- "Introduction": !!file parts/0029.txt
|
72
|
-
- "HTTP": !!file parts/0030.txt
|
73
|
-
- "SOCKS": !!file parts/0031.txt
|
data/doc/manual/page.erb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title><%= manual.product.name %> Manual<% if object %> :: <%= object.page_title %><% end %></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"><%= manual.product.name %>—</span><br />
|
13
|
-
<span class="tagline"><%= manual.product.tagline %></span>
|
14
|
-
</div>
|
15
|
-
</td><td valign='middle' align='right'>
|
16
|
-
<div class="info">
|
17
|
-
<%= manual.product.name %> Version: <strong><%= manual.product.version %></strong><br />
|
18
|
-
Manual Last Updated: <strong><%= Time.now.gmtime.strftime('%Y-%m-%d %H:%M %Z') %></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><%= manual.product.name %> Manual</h1>
|
29
|
-
|
30
|
-
<h2>Chapters</h2>
|
31
|
-
<ol type="I">
|
32
|
-
<% manual.chapters.each do |c| %>
|
33
|
-
<li><%= "<strong>" if c == object %>
|
34
|
-
<a href="chapter-<%= c.index %>.html">
|
35
|
-
<%= c.title %>
|
36
|
-
</a>
|
37
|
-
<%= "</strong> <big>←</big>" if c == object %>
|
38
|
-
<ol type="1">
|
39
|
-
<% c.sections.each do |s|
|
40
|
-
next unless s.title %>
|
41
|
-
<li><a href="chapter-<%= c.index %>.html#s<%= s.index %>"><%= s.title %></a></li>
|
42
|
-
<% end %>
|
43
|
-
</ol>
|
44
|
-
</li>
|
45
|
-
<% end %>
|
46
|
-
</ol>
|
47
|
-
|
48
|
-
<h2>Other Documentation</h2>
|
49
|
-
|
50
|
-
<ul>
|
51
|
-
<li><a href="http://net-ssh.rubyforge.org/api/index.html">Net::SSH API</a></li>
|
52
|
-
<li><a href="http://rubyforge.org/tracker/?atid=1842&group_id=274&func=browse">Net::SSH FAQ</a></li>
|
53
|
-
</ul>
|
54
|
-
|
55
|
-
<h2>Tutorials</h2>
|
56
|
-
<ol>
|
57
|
-
<% manual.tutorials.each do |t| %>
|
58
|
-
<li><%= "<strong>" if t == object %>
|
59
|
-
<a href="tutorial-<%= t.index %>.html">
|
60
|
-
<%= t.title %>
|
61
|
-
</a>
|
62
|
-
<%= "</strong> <big>←</big>" if t == object %><br />
|
63
|
-
<%= t.brief.to_html %>
|
64
|
-
</li>
|
65
|
-
<% end %>
|
66
|
-
</ol>
|
67
|
-
|
68
|
-
<p align="center"><strong>More To Come...</strong></p>
|
69
|
-
|
70
|
-
<div class="license">
|
71
|
-
<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 />
|
72
|
-
This manual is licensed under a <a href="http://creativecommons.org/licenses/by-sa/2.0/">Creative Commons License</a>.
|
73
|
-
</div>
|
74
|
-
</div>
|
75
|
-
|
76
|
-
</td><td valign='top' width="100%">
|
77
|
-
|
78
|
-
<div id="content">
|
79
|
-
|
80
|
-
<%= guts %>
|
81
|
-
|
82
|
-
</div>
|
83
|
-
|
84
|
-
</td></tr>
|
85
|
-
</table>
|
86
|
-
</body>
|
87
|
-
</html>
|
data/doc/manual/parts/0000.txt
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
Net::SSH is a pure-Ruby implementation of the SSH2 client protocol. It supports the following features:
|
2
|
-
|
3
|
-
* User authentication via explicit username/password, or using a public-key/private-key pair.
|
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.
|
5
|
-
* Execute processes on the remote machine, both interactively and non-interactively ("batch").
|
data/doc/manual/parts/0001.txt
DELETED
@@ -1,3 +0,0 @@
|
|
1
|
-
Net::SSH is only a _client_ implementation, not a server. Given sufficient motivation and encouragement from the community, perhaps it will someday include an SSH server, but as of right now, it does not.
|
2
|
-
|
3
|
-
Furthermore, it is only an _SSH2_ client. This means that it cannot connect to SSH servers that only understand the older SSH1 protocol.
|
data/doc/manual/parts/0002.txt
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
h3. Prerequisites:
|
2
|
-
|
3
|
-
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 "Net::SSH downloads page":http://rubyforge.org/projects/net-ssh.
|
4
|
-
|
5
|
-
Furthermore, you must make sure that Ruby's OpenSSL module has been compiled against _at least_ version 0.9.7 of the OpenSSL library. Prior versions lacked functionality that Net::SSH depends on (notably, the 'padding' property of ciphers).
|
6
|
-
|
7
|
-
Optionally, you can install the "ruby-termios":http://raa.ruby-lang.org/project/ruby-termios. If you do, then your passwords won't be echoed to the screen when prompting you for the passphrases needed to load your keys (if your keys have passphrases).
|
8
|
-
|
9
|
-
h3. Using "RubyGems":http://rubygems.rubyforge.org
|
10
|
-
|
11
|
-
If you have "RubyGems":http://rubygems.rubyforge.org installed, installing Net::SSH is simple:
|
12
|
-
|
13
|
-
{{{lang=shell,caption=Using Rubygems to install Net::SSH
|
14
|
-
gem install net-ssh
|
15
|
-
}}}
|
16
|
-
|
17
|
-
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!
|
18
|
-
|
19
|
-
h3. Using "rpa-base":http://rpa-base.rubyforge.org
|
20
|
-
|
21
|
-
If you have "rpa-base":http://rpa-base.rubyforge.org installed:
|
22
|
-
|
23
|
-
{{{lang=shell,caption=Using RPA to install Net::SSH
|
24
|
-
rpa install net-ssh
|
25
|
-
}}}
|
26
|
-
|
27
|
-
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!
|
28
|
-
|
29
|
-
h3. Doing it the hard way
|
30
|
-
|
31
|
-
If you don't have "RubyGems":http://rubygems.rubyforge.org or "rpa-base":http://rpa-base.rubyforge.org, or if you just prefer to install things by hand, you can always go to the "Net::SSH downloads page":http://rubyforge.org/projects/net-ssh and grab the package of your choice: @tar.gz@, @tar.bz2@, or @zip@.
|
32
|
-
|
33
|
-
Then, unpack the archive and run the @setup.rb@ script:
|
34
|
-
|
35
|
-
{{{lang=shell,caption=Using setup.rb to install Net::SSH
|
36
|
-
ruby setup.rb config
|
37
|
-
ruby setup.rb setup
|
38
|
-
ruby setup.rb install
|
39
|
-
}}}
|
40
|
-
|
data/doc/manual/parts/0003.txt
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
Net::SSH is made available under either the BSD license, or the same license Ruby (which, by extension, also allows the GPL as a permissable license as well). You can view the full text of any of these licenses in the @doc@ subdirectory of the Net::SSH distrubtion. The texts of the BSD and GPL licenses are also available online: "BSD":http://www.opensource.org/licenses/bsd-license.php and "GPL":http://www.opensource.org/licenses/gpl-license.php.
|
2
|
-
|
3
|
-
This manual (in any form, be it source or otherwise) and the scripts and templates used to generate it, are all distributed under the "Creative Commons":http://creativecommons.org "Attribution-ShareAlike":http://creativecommons.org/licenses/by-sa/2.0 license.
|
4
|
-
|
5
|
-
If you desire permission to use either Net::SSH or the manual in a manner incompatible with these licenses, please contact the copyright holder ("Jamis Buck":mailto:jamis@37signals.com) in order to negotiate a more compatible license.
|
6
|
-
|
data/doc/manual/parts/0004.txt
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
Mailing lists, bug trackers, feature requests, and public forums are all available (courtesty of "RubyForge":http://rubyforge.org) at the "Net::SSH project page":http://rubyforge.org/projects/net-ssh.
|
2
|
-
|
3
|
-
h3. Mailing Lists
|
4
|
-
|
5
|
-
|_. *List Name* |_. -- |_. *Description* |
|
6
|
-
|^=. "net-ssh-users":http://rubyforge.org/pipermail/net-ssh-users|^=. "subscribe / unsubscribe":http://rubyforge.org/mailman/listinfo/net-ssh-users| 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.|
|
7
|
-
|^=. "net-ssh-devel":http://rubyforge.org/pipermail/net-ssh-devel|^=. "subscribe / unsubscribe":http://rubyforge.org/mailman/listinfo/net-ssh-devel| 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.|
|
data/doc/manual/parts/0005.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Net::SSH was written by "Jamis Buck":mailto:jamis@37signals.com. 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 "Net::SSH project page":http://rubyforge.org/projects/net-ssh.
|
data/doc/manual/parts/0006.txt
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
Before you can do anything with Net::SSH, you need to require the @net/ssh@ module:
|
2
|
-
|
3
|
-
{{{lang=ruby,caption=Requiring Net::SSH
|
4
|
-
require 'net/ssh'
|
5
|
-
}}}
|
6
|
-
|
7
|
-
Once you have required the @net/ssh@ module, you can begin an SSH session by calling @Net::SSH.start@. This may be used in one of two ways. If called without a block, it will return a reference to the new session as an instance of a @Net::SSH::Session@. Used this way, you must explicitly close the session when you are finished with it.
|
8
|
-
|
9
|
-
{{{lang=ruby,number=true,caption=Opening an SSH session
|
10
|
-
session = Net::SSH.start( 'host', 'user', 'passwd' )
|
11
|
-
...
|
12
|
-
session.close
|
13
|
-
}}}
|
14
|
-
|
15
|
-
The other approach involves attaching a block to the start method. When used this way, the new session is passed to the block, and the session is automatically closed when the block exits.
|
16
|
-
|
17
|
-
{{{lang=ruby,number=true,caption=Opening a transactional SSH session
|
18
|
-
Net::SSH.start( 'host', 'user', 'passwd' ) do |session|
|
19
|
-
...
|
20
|
-
end
|
21
|
-
}}}
|
22
|
-
|
23
|
-
If you need to specify a different port on the host to connect to (the default is 22), you can specify it immediately after the @host@ parameter, like so:
|
24
|
-
|
25
|
-
{{{lang=ruby,number=true,caption=Specifying the SSH port
|
26
|
-
Net::SSH.start( 'host', 1234, 'user', 'passwd' ) do |session|
|
27
|
-
...
|
28
|
-
end
|
29
|
-
}}}
|
30
|
-
|
31
|
-
h3. Using Keyword Arguments
|
32
|
-
|
33
|
-
Some people prefer using keyword arguments for functions with more than a couple of parameters. The @start@ method supports this approach as well, although the @host@ parameter is always positional and always comes first.
|
34
|
-
|
35
|
-
{{{lang=ruby,number=true,caption=Using keyword arguments
|
36
|
-
Net::SSH.start( 'host',
|
37
|
-
:password=>'passwd',
|
38
|
-
:port=>1234,
|
39
|
-
:username=>'user',
|
40
|
-
... ) do |session|
|
41
|
-
...
|
42
|
-
end
|
43
|
-
}}}
|
44
|
-
|
45
|
-
(More about the "@...@" stuff, later.)
|
46
|
-
|
47
|
-
h3. Failed Authentication
|
48
|
-
|
49
|
-
If the username and/or password given to @start@ are incorrect, authentication will fail. If authentication fails, a @Net::SSH::AuthenticationFailed@ exception will be raised.
|
data/doc/manual/parts/0007.txt
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
Just as with the "OpenSSH":http://www.openssh.org version of the @ssh@ utilities, Net::SSH supports authentication using public/private keys.
|
2
|
-
|
3
|
-
h3. I don't know what public/private keys are... Explain, please?
|
4
|
-
|
5
|
-
Public key/private key encryption is just one way of hiding information from prying eyes. The idea is that you have two tokens: a _public key_, and a _private key_. The private key is yours alone--you never let _anyone_ else see it. The _public key_, on the other hand, is distributable. You give it to anyone that you want to be able to communicate with you securely.
|
6
|
-
|
7
|
-
The remote party uses your public key to encrypt information. Anything encrypted with your public key may only be decrypted with the corresponding private key, and since you have the only copy of that, you can rest easily knowing that no one can easily intercept your communications!
|
8
|
-
|
9
|
-
Net::SSH allows you to define a private key, which it will then attempt to use during authentication with the remote server. If the remote server has a copy of the corresponding public key, you will be able to log into that remote server without having to specify a password. Not only is this convenient, but for Ruby scripts, it is much more secure, since you don't have to hard-code your password in your script.
|
10
|
-
|
11
|
-
h3. Setting up public/private keys
|
12
|
-
|
13
|
-
Net::SSH, by default, will use the private keys that you have set up for use with ssh. These keys are called "id_dsa" and "id_rsa", and are located under your home directory, either in a ".ssh" subdirectory, or a ".ssh2" subdirectory.
|
14
|
-
|
15
|
-
The "id_dsa" key is the preferred key (since it uses the stronger DSA encryption), but both DSA and RSA are supported.
|
16
|
-
|
17
|
-
To create these keys, you can use the "ssh-keygen" utility from "OpenSSH":http://www.openssh.org. Alternatively, if you have the Net::SSH::Utilities package installed, you can use the "rb-keygen" utility (which is a pure-Ruby implementation of most of the functionality of ssh-keygen).
|
18
|
-
|
19
|
-
{{{lang=shell,caption=Generating an SSH key
|
20
|
-
ssh-keygen -t dsa
|
21
|
-
}}}
|
22
|
-
|
23
|
-
(If you would rather use an RSA key, replace "dsa" with "rsa" in the command given above.)
|
24
|
-
|
25
|
-
Accept all the defaults when prompted. You will also be asked for a passphrase. This passphrase is an additional level of protection, which prevents anyone from being able to use your private key without knowing the passphrase. Unfortunately, it also means that you have to enter the passphrase every time you use your key. It is up to you what price you want to pay for security, but if you _can_ leave the passphrase blank. In this case, anyone that has a copy of your private key can use it, but it's a little more convenient to deal with.
|
26
|
-
|
27
|
-
Once you create your keys, you then need to set up your account on each remote server so that it knows about your public key. To do this, log into the remote server and edit (or create) the file (in your home directory) ".ssh/authorized_keys". Just copy the contents of your public key (in your local machine's home directory, called ".ssh/id_dsa.pub" or ".ssh/id_rsa.pub") into the "authorized_keys" file on a line of its own. Then save the file and logout. Everything _should_ now be set up.
|
28
|
-
|
29
|
-
(Note: if you have an SSH client installed, it will typically have its own key generation utility. You can use that instead, if you prefer.)
|
30
|
-
|
31
|
-
h3. Connecting using public/private keys
|
32
|
-
|
33
|
-
Public/private keys are always tried before the explicit password authentication, even if you provide a password. Thus, if you _only_ want to use public/private key authentication, simply remove the password from the argument list. If you can successfully obtain a session handle, then your keys are set up correctly!
|
34
|
-
|
35
|
-
{{{lang=ruby,number=true,caption=SSH authentication using keys
|
36
|
-
Net::SSH.start( 'host', 'user' ) do |session|
|
37
|
-
...
|
38
|
-
end
|
39
|
-
}}}
|
40
|
-
|
41
|
-
Furthermore, if your @USER@ environment variable is set to the username that you want to log into the remote machine as, you can even leave the @username@ parameter off:
|
42
|
-
|
43
|
-
{{{lang=ruby,number=true,caption=Authentication with an implicit user name
|
44
|
-
Net::SSH.start( 'host' ) do |session|
|
45
|
-
...
|
46
|
-
end
|
47
|
-
}}}
|
48
|
-
|
49
|
-
h3. Using keys with passphrases
|
50
|
-
|
51
|
-
When you use a private key that was created with a passphrase, you will be prompted to enter the passphrase when the key is loaded. This may make such a key inappropriate for use in automated environments, but it is certainly more secure than the use of unprotected private keys.
|
52
|
-
|
53
|
-
h3. Using an SSH agent
|
54
|
-
|
55
|
-
Most SSH clients come with what is called an _agent_. This is a program that is continually running, and which keeps track of all of a user's keys. When an SSH client needs to perform an operation using one of the user's keys, it requests the operation via the agent, rather than performing the operation itself directly with a key.
|
56
|
-
|
57
|
-
The benefit of this is what is known as _single sign-on_. If any of your keys have a passphrase, this allows you to enter the passphrase _once_ (when the key is loaded by the agent), and then any SSH program you use will never prompt you for that passphrase again.
|
58
|
-
|
59
|
-
Net::SSH includes support for interfacing with an SSH agent. This includes support for the "PuTTY agent (pageant)":http://www.chiark.greenend.org.uk/~sgtatham/putty/ on Windows systems.
|
60
|
-
|
61
|
-
On Unixish systems, you allow your Net::SSH programs to interface with a running agent by making sure that the @SSH_AGENT_SOCK@ environment variable is set to the location of the Unix domain socket that the agent is listening to. Also, make sure you have added all of your keys to the agent (typically by running the @ssh-add@ utility.
|
62
|
-
|
63
|
-
On Windows, the pageant process will be detected automatically, if it is running.
|
64
|
-
|
65
|
-
A future version of Net::SSH may include it's own agent implementation as well, to make using an agent on a variety of platforms simpler.
|
66
|
-
|
67
|
-
Agent forwarding is available, and may be requested with the :forward_agent option to Net::SSH.start. Agents are not forwarded by default.
|
data/doc/manual/parts/0008.txt
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
There are various additional options that you can specify when connecting. These options allow you to specify such things as the cipher algorithm to use, whether or not the data stream will be compressed, or explicit paths to the private keys to use.
|
2
|
-
|
3
|
-
Options are specified as a hash in the last parameter to the @start@ method. If using the keyword parameters version of the @start@ method, the options hash is whatever is left after processing the @:username@, @:password@, and @:port@ options.
|
4
|
-
|
5
|
-
The complete list of available options, and their valid values, is given in the following table.
|
6
|
-
|
7
|
-
table(list).
|
8
|
-
|_. Option |_. Description |
|
9
|
-
|^=. @:auth_methods@ | This is the list of authorization methods to try. It defaults to "publickey", "hostbased", "password", and "keyboard-interactive". (These are also the only authorization methods that are supported.) If you want them to be tried in a different order, or if you don't want certain methods to be used, you can specify your own list via this option.|
|
10
|
-
|^=. @:compression@ | The compression algorithm to use when compressing the data stream. Valid values are @none@ and @zlib@. The default is @none@.|
|
11
|
-
|^=. @:compression_level@ | This is only used when the compression algorithm is @zlib@. It is an integer value from 0 to 9, representing the quality of the compression. A 0 is no compression, and a 9 is most compression. The default is 6.|
|
12
|
-
|^=. @:container@ | This is the dependency injection container to use when registering all of the services that Net::SSH uses internally. If unspecified (the default) a new container will be created. This option allows you to reuse a single container for multiple application components.|
|
13
|
-
|^=. @:crypto_backend@ | This is the cryptography backend to use. It defaults to @:ossl@, which specifies the OpenSSL cryptography engine. Currently, this is the only supported backend, but in the future others may be provided, and this is how they would be selected.|
|
14
|
-
|^=. @:encryption@ | This is the cipher algorithm to use when sending/receiving data to/from the remote server. It defaults to @3des-cbc@. Other valid algorithms supported by Net::SSH are @aes128-cbc@, @blowfish-cbc@, @aes256-cbc@, @aes192-cbc@, @idea-cbc@, and @none@. Note that the values you specify here are only _suggestions_, and if the server you are contacting cannot use your recommended algorithm, a fallback algorithm will be used (typically chosen in the order the algorithms were listed, above). This option may take an array, if you want to specify the order of the fallback algorithms to try, as well. |
|
15
|
-
|^=. @:forward_agent@ | Set to a true value to request that the local authentication agent be forwarded to the remote host. By default the agent will not be forwarded. |
|
16
|
-
|^=. @:hmac@ | This specifies the "message authentication code" (MAC) algorithm to use to ensure that each packet transmitted and recieved is authentic. This defaults to @hmac-md5@. Other valid algorithms supported by Net::SSH are @hmac-sha1@, @hmac-md5-96@, @hmac-md5-sha1@, and @none@. Note that the values you specify here are only _suggestions_, and if the server you are contacting cannot use your recommended algorithm, a fallback algorithm will be used (typically chosen in the order the algorithms were listed, above). This option may take an array, if you want to specify the order of the fallback algorithms to try, as well. |
|
17
|
-
|^=. @:host_key@ | This specifies the host key type that should be used when negotiating keys with the server. This defaults to @ssh-dss@, but may also be @ssh-rsa@. As with some other option types, the value you specify is only a recommendation, not a commandment, and if the server cannot honor the key type you specified, a fallback will be chosen from among the other supported types. If you wish to specify the fallback algorithms to try, you may pass an array as the value of this option, which contains (in order) the key types to try. |
|
18
|
-
|^=. @:host_keys@ | This is an array of file names that contain the private keys which identify the host your script is running on. These default to @/etc/ssh/ssh_host_dsa_key@ and @/etc/ssh/ssh_host_rsa_key@ (which are both typically only readable by root). These keys are only used in hostbased authentication.|
|
19
|
-
|^=. @:kex@ | This specifies the "key-exchange" (KEX) algorithm to use when exchanging keys. Two algorithms are currently supported: @diffie-hellman-group-exchange-sha1@, and @diffie-hellman-group1-sha1@. The default is @diffie-hellman-group-exchange-sha1@.|
|
20
|
-
|^=. @:keys@ | This specifies the list of private key files to use _instead_ of the defaults (@$HOME/.ssh/id_dsa@, @$HOME/.ssh2/id_dsa@, @$HOME/.ssh/id_rsa@, and @$HOME/.ssh2/id_rsa@). The value of this option should be an array of strings.|
|
21
|
-
|^=. @:languages@ | This option specifies the preferred language (or languages) that should be used when communicating error messages. It has no effect on Net::SSH, but may cause the server (if it supports your suggested language) to send errors in the language you request. The default is empty.|
|
22
|
-
|^=. @:log@ | Specifies either a string or an IO object. If it is a string, it names the file that all log messages should be written to. Otherwise, the messages will be written to the IO object directly. Defaults to STDERR.|
|
23
|
-
|^=. @:paranoid@ | Controls how Net::SSH responds to a server key that it does not recognize. The default, @true@, will result in all keys being accepted the first time they are seen for a particular host, and then an exception being raised if the key ever changes. However, no host key verification will be done if the connection appears to be tunneled over a locally forwarded port. If set to @false@, no server key verification is done. You can also set this to @:very@, in which case errors are raised even if the connection appears to be tunneled.|
|
24
|
-
|^=. @:port@ | This is the port number that should be used to connect to the remote machine. If you wish to specify the port, you are generally better off specifying it as the second parameter to @start@, rather than as an option, but you _can_ specify it this way, if you prefer.|
|
25
|
-
|^=. @:registry_options@ | If the @:container@ option is not specified, a new container will be created. This option specifies a hash of additional options that may be used to configure the new container (registry). By default, it is empty.|
|
26
|
-
|^=. @:verbose@ | Specifies how verbose the logging should be. Valid values are @:fatal@, @:error@, @:warn@, @:info@, and @:debug@. Defaults to @:warn@. WARNING: selecting @:debug@ will result in LOTS of output! (Further customization of verbosity can be accomplished by specifying which Net::SSH components should have which logging levels, via the @:registry_options@ option.)|
|
27
|
-
|
28
|
-
For example, the following code snippet will connect to the given remote host, and requests that the @ssh-rsa@ host key type be used, with the @blowfish-cbc@ cipher algorithm, and requests that the given private key file be used. Also, the data stream will be compressed.
|
29
|
-
|
30
|
-
{{{lang=ruby,number=true,caption=Specifying options when connecting
|
31
|
-
require 'net/ssh'
|
32
|
-
require 'logger'
|
33
|
-
|
34
|
-
Net::SSH.start(
|
35
|
-
'host', 'user',
|
36
|
-
:host_key => "ssh-rsa",
|
37
|
-
:encryption => "blowfish-cbc",
|
38
|
-
:keys => [ "/tmp/temporary-key" ],
|
39
|
-
:compression => "zlib"
|
40
|
-
) do |session|
|
41
|
-
...
|
42
|
-
end
|
43
|
-
}}}
|
data/doc/manual/parts/0009.txt
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
Alternatively, you can use @Net::SSH::Session@ to start your SSH sessions. The @Net::SSH.start@ interface described above is simply a convenience for creating a new Session object explicitly.
|
2
|
-
|
3
|
-
{{{lang=ruby,number=true,caption=Using Net::SSH::Session
|
4
|
-
require 'net/ssh'
|
5
|
-
|
6
|
-
Net::SSH::Session.new(
|
7
|
-
'host', 'username', 'password',
|
8
|
-
:compression => "zlib"
|
9
|
-
) do |session|
|
10
|
-
...
|
11
|
-
end
|
12
|
-
}}}
|
13
|
-
|
14
|
-
Note that @Net::SSH::Session#new@ accepts the same parameters as Net::SSH.start, and may also be called without a block.
|
data/doc/manual/parts/0010.txt
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
The SSH protocol requires that requests for services on a remote machine be made over _channels_. A single SSH connection may contain multiple channels, all run simultaneously over that connection.
|
2
|
-
|
3
|
-
Each channel, in turn, represents the processing of a single service. When you invoke a process on the remote host with Net::SSH, a channel is opened for that invocation, and all input and output relevant to that process is sent through that channel. The connection itself simply manages the packets of all of the channels that it has open.
|
4
|
-
|
5
|
-
This means that, for instance, over a single SSH connection you could execute a process, download a file via SFTP, and forward any number of ports, all (seemingly) at the same time!
|
6
|
-
|
7
|
-
Naturally, they do not occur simultaneously, but rather work in a "time-share" fashion by sharing the bandwidth of the connection. Nevertheless, the fact that these channels exist make working with the SSH protocol a bit more challenging than simpler protocols (like FTP, HTTP, or Telnet).
|
data/doc/manual/parts/0011.txt
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
Because a session may be composed of multiple simultaneously operating channels, the Net::SSH interface works by means of _callbacks_. You specify actions that need to occur in response to various events, and when those events occur, the framework invokes the corresonding callbacks.
|
2
|
-
|
3
|
-
In order to allow the events to be processed in a continuous manner, you need to be sure to call the @loop@ method of your session handle, after setting up any callbacks that you want to be executed. If you do not call the @loop@ method, your session will terminate as soon as the block is exited, which means none of your carefully laid callbacks will ever be called.
|
4
|
-
|
5
|
-
The @loop@ method is easy to invoke:
|
6
|
-
|
7
|
-
{{{lang=ruby,caption=Session#loop,number=true
|
8
|
-
Net::SSH.start( 'host' ) do |session|
|
9
|
-
...
|
10
|
-
session.loop
|
11
|
-
end
|
12
|
-
}}}
|
13
|
-
|
14
|
-
Incidentally, the @loop@ method accepts an optional block, which if specified should return a "false" value when the loop should terminate. In the absense of a block, the loop will continue until there are no more open channels. Sometimes, however, you only want the loop to continue until some action occurs, at which time you then do some processing and then start the loop again.
|
data/doc/manual/parts/0012.txt
DELETED
@@ -1,3 +0,0 @@
|
|
1
|
-
Each channel has a _type_. Usually, you will use "session" channels, but there are also "x11" channels, "forwarded-tcpip" channels, and "direct-tcpip" channels. Net::SSH currently has no support for "x11" channels. The "forwarded-tcpip" and "direct-tcpip" channels are managed internally via the port-forwarding interfaces.
|
2
|
-
|
3
|
-
The "session" channel type allows for a broad range of actions, including (but not limited to) SFTP requests and remote process execution.
|
data/doc/manual/parts/0013.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
The simplest way to open a channel is via the @open_channel@ method of Net::SSH::Session. By default, the channel will be of type "session", but you can optionally specify the channel type and any extra data to initialize the channel with. You also pass a block to the @open_channel@ invocation. This block will be called after the server has confirmed that the channel is valid and has been opened successfully.
|
2
|
-
|
3
|
-
The @open_channel@ method always returns immediately--all it does is inform the server that a channel needs to be opened and then registers the associated block as the callback to be invoked when the channel is confirmed.
|
4
|
-
|
5
|
-
This behavior is typical of most of the methods in the Net::SSH API; they simply send a request to the server and then (optionally) register a callback. Very few of them actually block (pause) until the server responds.
|
6
|
-
|
7
|
-
Here is an example of opening a channel:
|
8
|
-
|
9
|
-
{{{lang=ruby,caption=Opening a channel,number=true
|
10
|
-
Net::SSH.start( 'host' ) do |session|
|
11
|
-
session.open_channel do |channel|
|
12
|
-
puts "channel successfully opened... closing..."
|
13
|
-
channel.close
|
14
|
-
end
|
15
|
-
|
16
|
-
session.loop
|
17
|
-
end
|
18
|
-
}}}
|
19
|
-
|
20
|
-
Note the use of the @close@ method for the channel. Just like most methods in the Net::SSH API, it does not immediately close the channel, but instead sends a close request to the server and returns. When the server responds that the channel has been closed, the framework will then call any final callbacks for the channel and then remove it.
|