net-ssh 3.2.0.rc2 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +2 -2
- data/.dockerignore +6 -0
- data/.github/config/rubocop_linter_action.yml +4 -0
- data/.github/workflows/ci-with-docker.yml +44 -0
- data/.github/workflows/ci.yml +87 -0
- data/.github/workflows/rubocop.yml +16 -0
- data/.gitignore +13 -0
- data/.rubocop.yml +22 -0
- data/.rubocop_todo.yml +1081 -0
- data/CHANGES.txt +228 -7
- data/Dockerfile +27 -0
- data/Dockerfile.openssl3 +17 -0
- data/Gemfile +13 -0
- data/Gemfile.noed25519 +12 -0
- data/ISSUE_TEMPLATE.md +30 -0
- data/Manifest +4 -5
- data/README.md +297 -0
- data/Rakefile +125 -74
- data/SECURITY.md +4 -0
- data/appveyor.yml +58 -0
- data/docker-compose.yml +23 -0
- data/lib/net/ssh/authentication/agent.rb +279 -18
- data/lib/net/ssh/authentication/certificate.rb +183 -0
- data/lib/net/ssh/authentication/constants.rb +17 -15
- data/lib/net/ssh/authentication/ed25519.rb +186 -0
- data/lib/net/ssh/authentication/ed25519_loader.rb +31 -0
- data/lib/net/ssh/authentication/key_manager.rb +86 -39
- data/lib/net/ssh/authentication/methods/abstract.rb +67 -48
- data/lib/net/ssh/authentication/methods/hostbased.rb +34 -37
- data/lib/net/ssh/authentication/methods/keyboard_interactive.rb +13 -13
- data/lib/net/ssh/authentication/methods/none.rb +16 -19
- data/lib/net/ssh/authentication/methods/password.rb +27 -17
- data/lib/net/ssh/authentication/methods/publickey.rb +96 -55
- data/lib/net/ssh/authentication/pageant.rb +471 -367
- data/lib/net/ssh/authentication/pub_key_fingerprint.rb +43 -0
- data/lib/net/ssh/authentication/session.rb +131 -121
- data/lib/net/ssh/buffer.rb +399 -300
- data/lib/net/ssh/buffered_io.rb +154 -150
- data/lib/net/ssh/config.rb +308 -185
- data/lib/net/ssh/connection/channel.rb +635 -613
- data/lib/net/ssh/connection/constants.rb +29 -29
- data/lib/net/ssh/connection/event_loop.rb +123 -0
- data/lib/net/ssh/connection/keepalive.rb +55 -51
- data/lib/net/ssh/connection/session.rb +620 -551
- data/lib/net/ssh/connection/term.rb +125 -123
- data/lib/net/ssh/errors.rb +101 -99
- data/lib/net/ssh/key_factory.rb +197 -105
- data/lib/net/ssh/known_hosts.rb +214 -127
- data/lib/net/ssh/loggable.rb +50 -49
- data/lib/net/ssh/packet.rb +83 -79
- data/lib/net/ssh/prompt.rb +50 -81
- data/lib/net/ssh/proxy/command.rb +105 -90
- data/lib/net/ssh/proxy/errors.rb +12 -10
- data/lib/net/ssh/proxy/http.rb +82 -79
- data/lib/net/ssh/proxy/https.rb +50 -0
- data/lib/net/ssh/proxy/jump.rb +54 -0
- data/lib/net/ssh/proxy/socks4.rb +2 -6
- data/lib/net/ssh/proxy/socks5.rb +14 -17
- data/lib/net/ssh/service/forward.rb +370 -317
- data/lib/net/ssh/test/channel.rb +145 -136
- data/lib/net/ssh/test/extensions.rb +131 -110
- data/lib/net/ssh/test/kex.rb +34 -32
- data/lib/net/ssh/test/local_packet.rb +46 -44
- data/lib/net/ssh/test/packet.rb +89 -70
- data/lib/net/ssh/test/remote_packet.rb +32 -30
- data/lib/net/ssh/test/script.rb +156 -142
- data/lib/net/ssh/test/socket.rb +49 -48
- data/lib/net/ssh/test.rb +82 -77
- data/lib/net/ssh/transport/algorithms.rb +441 -360
- data/lib/net/ssh/transport/cipher_factory.rb +96 -98
- data/lib/net/ssh/transport/constants.rb +32 -24
- data/lib/net/ssh/transport/ctr.rb +42 -22
- data/lib/net/ssh/transport/hmac/abstract.rb +81 -63
- data/lib/net/ssh/transport/hmac/md5.rb +0 -2
- data/lib/net/ssh/transport/hmac/md5_96.rb +0 -2
- data/lib/net/ssh/transport/hmac/none.rb +0 -2
- data/lib/net/ssh/transport/hmac/ripemd160.rb +0 -2
- data/lib/net/ssh/transport/hmac/sha1.rb +0 -2
- data/lib/net/ssh/transport/hmac/sha1_96.rb +0 -2
- data/lib/net/ssh/transport/hmac/sha2_256.rb +7 -11
- data/lib/net/ssh/transport/hmac/sha2_256_96.rb +4 -8
- data/lib/net/ssh/transport/hmac/sha2_256_etm.rb +12 -0
- data/lib/net/ssh/transport/hmac/sha2_512.rb +6 -9
- data/lib/net/ssh/transport/hmac/sha2_512_96.rb +4 -8
- data/lib/net/ssh/transport/hmac/sha2_512_etm.rb +12 -0
- data/lib/net/ssh/transport/hmac.rb +14 -12
- data/lib/net/ssh/transport/identity_cipher.rb +54 -52
- data/lib/net/ssh/transport/kex/abstract.rb +130 -0
- data/lib/net/ssh/transport/kex/abstract5656.rb +72 -0
- data/lib/net/ssh/transport/kex/curve25519_sha256.rb +39 -0
- data/lib/net/ssh/transport/kex/curve25519_sha256_loader.rb +30 -0
- data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +33 -40
- data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha256.rb +11 -0
- data/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +119 -213
- data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +53 -61
- data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +5 -9
- data/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +36 -90
- data/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +18 -10
- data/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +18 -10
- data/lib/net/ssh/transport/kex.rb +15 -12
- data/lib/net/ssh/transport/key_expander.rb +24 -20
- data/lib/net/ssh/transport/openssl.rb +161 -124
- data/lib/net/ssh/transport/packet_stream.rb +225 -185
- data/lib/net/ssh/transport/server_version.rb +55 -56
- data/lib/net/ssh/transport/session.rb +306 -255
- data/lib/net/ssh/transport/state.rb +178 -176
- data/lib/net/ssh/verifiers/accept_new.rb +33 -0
- data/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb +33 -0
- data/lib/net/ssh/verifiers/always.rb +58 -0
- data/lib/net/ssh/verifiers/never.rb +19 -0
- data/lib/net/ssh/version.rb +55 -53
- data/lib/net/ssh.rb +110 -47
- data/net-ssh-public_cert.pem +18 -18
- data/net-ssh.gemspec +36 -205
- data/support/ssh_tunnel_bug.rb +5 -5
- data.tar.gz.sig +0 -0
- metadata +153 -118
- metadata.gz.sig +0 -0
- data/.travis.yml +0 -18
- data/README.rdoc +0 -182
- data/lib/net/ssh/authentication/agent/java_pageant.rb +0 -85
- data/lib/net/ssh/authentication/agent/socket.rb +0 -178
- data/lib/net/ssh/ruby_compat.rb +0 -46
- data/lib/net/ssh/verifiers/lenient.rb +0 -30
- data/lib/net/ssh/verifiers/null.rb +0 -12
- data/lib/net/ssh/verifiers/secure.rb +0 -52
- data/lib/net/ssh/verifiers/strict.rb +0 -24
- data/setup.rb +0 -1585
- data/support/arcfour_check.rb +0 -20
- data/test/README.txt +0 -18
- data/test/authentication/methods/common.rb +0 -28
- data/test/authentication/methods/test_abstract.rb +0 -51
- data/test/authentication/methods/test_hostbased.rb +0 -114
- data/test/authentication/methods/test_keyboard_interactive.rb +0 -121
- data/test/authentication/methods/test_none.rb +0 -41
- data/test/authentication/methods/test_password.rb +0 -95
- data/test/authentication/methods/test_publickey.rb +0 -148
- data/test/authentication/test_agent.rb +0 -232
- data/test/authentication/test_key_manager.rb +0 -240
- data/test/authentication/test_session.rb +0 -107
- data/test/common.rb +0 -125
- data/test/configs/auth_off +0 -5
- data/test/configs/auth_on +0 -4
- data/test/configs/empty +0 -0
- data/test/configs/eqsign +0 -3
- data/test/configs/exact_match +0 -8
- data/test/configs/host_plus +0 -10
- data/test/configs/multihost +0 -4
- data/test/configs/negative_match +0 -6
- data/test/configs/nohost +0 -19
- data/test/configs/numeric_host +0 -4
- data/test/configs/proxy_remote_user +0 -2
- data/test/configs/send_env +0 -2
- data/test/configs/substitutes +0 -8
- data/test/configs/wild_cards +0 -14
- data/test/connection/test_channel.rb +0 -487
- data/test/connection/test_session.rb +0 -564
- data/test/integration/README.txt +0 -17
- data/test/integration/Vagrantfile +0 -12
- data/test/integration/common.rb +0 -63
- data/test/integration/playbook.yml +0 -56
- data/test/integration/test_forward.rb +0 -637
- data/test/integration/test_id_rsa_keys.rb +0 -96
- data/test/integration/test_proxy.rb +0 -93
- data/test/known_hosts/github +0 -1
- data/test/known_hosts/github_hash +0 -1
- data/test/manual/test_pageant.rb +0 -37
- data/test/start/test_connection.rb +0 -53
- data/test/start/test_options.rb +0 -57
- data/test/start/test_transport.rb +0 -28
- data/test/start/test_user_nil.rb +0 -27
- data/test/test_all.rb +0 -12
- data/test/test_buffer.rb +0 -433
- data/test/test_buffered_io.rb +0 -63
- data/test/test_config.rb +0 -268
- data/test/test_key_factory.rb +0 -191
- data/test/test_known_hosts.rb +0 -66
- data/test/transport/hmac/test_md5.rb +0 -41
- data/test/transport/hmac/test_md5_96.rb +0 -27
- data/test/transport/hmac/test_none.rb +0 -34
- data/test/transport/hmac/test_ripemd160.rb +0 -36
- data/test/transport/hmac/test_sha1.rb +0 -36
- data/test/transport/hmac/test_sha1_96.rb +0 -27
- data/test/transport/hmac/test_sha2_256.rb +0 -37
- data/test/transport/hmac/test_sha2_256_96.rb +0 -27
- data/test/transport/hmac/test_sha2_512.rb +0 -37
- data/test/transport/hmac/test_sha2_512_96.rb +0 -27
- data/test/transport/kex/test_diffie_hellman_group14_sha1.rb +0 -13
- data/test/transport/kex/test_diffie_hellman_group1_sha1.rb +0 -150
- data/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +0 -96
- data/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb +0 -19
- data/test/transport/kex/test_ecdh_sha2_nistp256.rb +0 -161
- data/test/transport/kex/test_ecdh_sha2_nistp384.rb +0 -38
- data/test/transport/kex/test_ecdh_sha2_nistp521.rb +0 -38
- data/test/transport/test_algorithms.rb +0 -328
- data/test/transport/test_cipher_factory.rb +0 -443
- data/test/transport/test_hmac.rb +0 -34
- data/test/transport/test_identity_cipher.rb +0 -40
- data/test/transport/test_packet_stream.rb +0 -1762
- data/test/transport/test_server_version.rb +0 -74
- data/test/transport/test_session.rb +0 -331
- data/test/transport/test_state.rb +0 -181
- data/test/verifiers/test_secure.rb +0 -40
@@ -1,178 +1,180 @@
|
|
1
|
-
module Net
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
module Net
|
2
|
+
module SSH
|
3
|
+
module Connection
|
4
|
+
# These constants are used when requesting a pseudo-terminal (via
|
5
|
+
# Net::SSH::Connection::Channel#request_pty). The descriptions for each are
|
6
|
+
# taken directly from RFC 4254 ("The Secure Shell (SSH) Connection Protocol"),
|
7
|
+
# http://tools.ietf.org/html/rfc4254.
|
8
|
+
module Term
|
9
|
+
# Interrupt character; 255 if none. Similarly for the other characters.
|
10
|
+
# Not all of these characters are supported on all systems.
|
11
|
+
VINTR = 1
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
# The quit character (sends SIGQUIT signal on POSIX systems).
|
14
|
+
VQUIT = 2
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
# Erase the character to left of the cursor.
|
17
|
+
VERASE = 3
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
# Kill the current input line.
|
20
|
+
VKILL = 4
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
# End-of-file character (sends EOF from the terminal).
|
23
|
+
VEOF = 5
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
# End-of-line character in addition to carriage return and/or linefeed.
|
26
|
+
VEOL = 6
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
# Additional end-of-line character.
|
29
|
+
VEOL2 = 7
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
# Continues paused output (normally control-Q).
|
32
|
+
VSTART = 8
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
# Pauses output (normally control-S).
|
35
|
+
VSTOP = 9
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
# Suspends the current program.
|
38
|
+
VSUSP = 10
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
# Another suspend character.
|
41
|
+
VDSUSP = 11
|
41
42
|
|
42
|
-
|
43
|
-
|
43
|
+
# Reprints the current input line.
|
44
|
+
VREPRINT = 12
|
44
45
|
|
45
|
-
|
46
|
-
|
46
|
+
# Erases a word left of cursor.
|
47
|
+
VWERASE = 13
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
# Enter the next character typed literally, even if it is a special
|
50
|
+
# character.
|
51
|
+
VLNEXT = 14
|
51
52
|
|
52
|
-
|
53
|
-
|
53
|
+
# Character to flush output.
|
54
|
+
VFLUSH = 15
|
54
55
|
|
55
|
-
|
56
|
-
|
56
|
+
# Switch to a different shell layer.
|
57
|
+
VSWITCH = 16
|
57
58
|
|
58
|
-
|
59
|
-
|
59
|
+
# Prints system status line (load, command, pid, etc).
|
60
|
+
VSTATUS = 17
|
60
61
|
|
61
|
-
|
62
|
-
|
62
|
+
# Toggles the flushing of terminal output.
|
63
|
+
VDISCARD = 18
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
# The ignore parity flag. The parameter SHOULD be 0 if this flag is FALSE,
|
66
|
+
# and 1 if it is TRUE.
|
67
|
+
IGNPAR = 30
|
67
68
|
|
68
|
-
|
69
|
-
|
69
|
+
# Mark parity and framing errors.
|
70
|
+
PARMRK = 31
|
70
71
|
|
71
|
-
|
72
|
-
|
72
|
+
# Enable checking of parity errors.
|
73
|
+
INPCK = 32
|
73
74
|
|
74
|
-
|
75
|
-
|
75
|
+
# Strip 8th bit off characters.
|
76
|
+
ISTRIP = 33
|
76
77
|
|
77
|
-
|
78
|
-
|
78
|
+
# Map NL into CR on input.
|
79
|
+
INCLR = 34
|
79
80
|
|
80
|
-
|
81
|
-
|
81
|
+
# Ignore CR on input.
|
82
|
+
IGNCR = 35
|
82
83
|
|
83
|
-
|
84
|
-
|
84
|
+
# Map CR to NL on input.
|
85
|
+
ICRNL = 36
|
85
86
|
|
86
|
-
|
87
|
-
|
87
|
+
# Translate uppercase characters to lowercase.
|
88
|
+
IUCLC = 37
|
88
89
|
|
89
|
-
|
90
|
-
|
90
|
+
# Enable output flow control.
|
91
|
+
IXON = 38
|
91
92
|
|
92
|
-
|
93
|
-
|
93
|
+
# Any char will restart after stop.
|
94
|
+
IXANY = 39
|
94
95
|
|
95
|
-
|
96
|
-
|
96
|
+
# Enable input flow control.
|
97
|
+
IXOFF = 40
|
97
98
|
|
98
|
-
|
99
|
-
|
99
|
+
# Ring bell on input queue full.
|
100
|
+
IMAXBEL = 41
|
100
101
|
|
101
|
-
|
102
|
-
|
102
|
+
# Enable signals INTR, QUIT, [D]SUSP.
|
103
|
+
ISIG = 50
|
103
104
|
|
104
|
-
|
105
|
-
|
105
|
+
# Canonicalize input lines.
|
106
|
+
ICANON = 51
|
106
107
|
|
107
|
-
|
108
|
-
|
109
|
-
|
108
|
+
# Enable input and output of uppercase characters by preceding their
|
109
|
+
# lowercase equivalents with "\".
|
110
|
+
XCASE = 52
|
110
111
|
|
111
|
-
|
112
|
-
|
112
|
+
# Enable echoing.
|
113
|
+
ECHO = 53
|
113
114
|
|
114
|
-
|
115
|
-
|
115
|
+
# Visually erase chars.
|
116
|
+
ECHOE = 54
|
116
117
|
|
117
|
-
|
118
|
-
|
118
|
+
# Kill character discards current line.
|
119
|
+
ECHOK = 55
|
119
120
|
|
120
|
-
|
121
|
-
|
121
|
+
# Echo NL even if ECHO is off.
|
122
|
+
ECHONL = 56
|
122
123
|
|
123
|
-
|
124
|
-
|
124
|
+
# Don't flush after interrupt.
|
125
|
+
NOFLSH = 57
|
125
126
|
|
126
|
-
|
127
|
-
|
127
|
+
# Stop background jobs from output.
|
128
|
+
TOSTOP = 58
|
128
129
|
|
129
|
-
|
130
|
-
|
130
|
+
# Enable extensions.
|
131
|
+
IEXTEN = 59
|
131
132
|
|
132
|
-
|
133
|
-
|
133
|
+
# Echo control characters as ^(Char).
|
134
|
+
ECHOCTL = 60
|
134
135
|
|
135
|
-
|
136
|
-
|
136
|
+
# Visual erase for line kill.
|
137
|
+
ECHOKE = 61
|
137
138
|
|
138
|
-
|
139
|
-
|
139
|
+
# Retype pending input.
|
140
|
+
PENDIN = 62
|
140
141
|
|
141
|
-
|
142
|
-
|
142
|
+
# Enable output processing.
|
143
|
+
OPOST = 70
|
143
144
|
|
144
|
-
|
145
|
-
|
145
|
+
# Convert lowercase to uppercase.
|
146
|
+
OLCUC = 71
|
146
147
|
|
147
|
-
|
148
|
-
|
148
|
+
# Map NL to CR-NL.
|
149
|
+
ONLCR = 72
|
149
150
|
|
150
|
-
|
151
|
-
|
151
|
+
# Translate carriage return to newline (output).
|
152
|
+
OCRNL = 73
|
152
153
|
|
153
|
-
|
154
|
-
|
154
|
+
# Translate newline to carriage return-newline (output).
|
155
|
+
ONOCR = 74
|
155
156
|
|
156
|
-
|
157
|
-
|
157
|
+
# Newline performs a carriage return (output).
|
158
|
+
ONLRET = 75
|
158
159
|
|
159
|
-
|
160
|
-
|
160
|
+
# 7 bit mode.
|
161
|
+
CS7 = 90
|
161
162
|
|
162
|
-
|
163
|
-
|
163
|
+
# 8 bit mode.
|
164
|
+
CS8 = 91
|
164
165
|
|
165
|
-
|
166
|
-
|
166
|
+
# Parity enable.
|
167
|
+
PARENB = 92
|
167
168
|
|
168
|
-
|
169
|
-
|
169
|
+
# Odd parity, else even.
|
170
|
+
PARODD = 93
|
170
171
|
|
171
|
-
|
172
|
-
|
172
|
+
# Specifies the input baud rate in bits per second.
|
173
|
+
TTY_OP_ISPEED = 128
|
173
174
|
|
174
|
-
|
175
|
-
|
175
|
+
# Specifies the output baud rate in bits per second.
|
176
|
+
TTY_OP_OSPEED = 129
|
177
|
+
end
|
178
|
+
end
|
176
179
|
end
|
177
|
-
|
178
|
-
end; end; end
|
180
|
+
end
|
data/lib/net/ssh/errors.rb
CHANGED
@@ -1,104 +1,106 @@
|
|
1
|
-
module Net
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
# Base class for host key exceptions. When rescuing this exception, you can
|
43
|
-
# inspect the key fingerprint and, if you want to proceed anyway, simply call
|
44
|
-
# the remember_host! method on the exception, and then retry.
|
45
|
-
class HostKeyError < Exception
|
46
|
-
# the callback to use when #remember_host! is called
|
47
|
-
attr_writer :callback #:nodoc:
|
48
|
-
|
49
|
-
# situation-specific data describing the host (see #host, #port, etc.)
|
50
|
-
attr_writer :data #:nodoc:
|
51
|
-
|
52
|
-
# An accessor for getting at the data that was used to look up the host
|
53
|
-
# (see also #fingerprint, #host, #port, #ip, and #key).
|
54
|
-
def [](key)
|
55
|
-
@data && @data[key]
|
56
|
-
end
|
57
|
-
|
58
|
-
# Returns the fingerprint of the key for the host, which either was not
|
59
|
-
# found or did not match.
|
60
|
-
def fingerprint
|
61
|
-
@data && @data[:fingerprint]
|
1
|
+
module Net
|
2
|
+
module SSH
|
3
|
+
# A general exception class, to act as the ancestor of all other Net::SSH
|
4
|
+
# exception classes.
|
5
|
+
class Exception < ::RuntimeError; end
|
6
|
+
|
7
|
+
# This exception is raised when authentication fails (whether it be
|
8
|
+
# public key authentication, password authentication, or whatever).
|
9
|
+
class AuthenticationFailed < Net::SSH::Exception; end
|
10
|
+
|
11
|
+
# This exception is raised when a connection attempt times out.
|
12
|
+
class ConnectionTimeout < Net::SSH::Exception; end
|
13
|
+
|
14
|
+
# This exception is raised when the remote host has disconnected
|
15
|
+
# unexpectedly.
|
16
|
+
class Disconnect < Net::SSH::Exception; end
|
17
|
+
|
18
|
+
# This exception is raised when the remote host has disconnected/
|
19
|
+
# timeouted unexpectedly.
|
20
|
+
class Timeout < Disconnect; end
|
21
|
+
|
22
|
+
# This exception is primarily used internally, but if you have a channel
|
23
|
+
# request handler (see Net::SSH::Connection::Channel#on_request) that you
|
24
|
+
# want to fail in such a way that the server knows it failed, you can
|
25
|
+
# raise this exception in the handler and Net::SSH will translate that into
|
26
|
+
# a "channel failure" message.
|
27
|
+
class ChannelRequestFailed < Net::SSH::Exception; end
|
28
|
+
|
29
|
+
# This is exception is primarily used internally, but if you have a channel
|
30
|
+
# open handler (see Net::SSH::Connection::Session#on_open_channel) and you
|
31
|
+
# want to fail in such a way that the server knows it failed, you can
|
32
|
+
# raise this exception in the handler and Net::SSH will translate that into
|
33
|
+
# a "channel open failed" message.
|
34
|
+
class ChannelOpenFailed < Net::SSH::Exception
|
35
|
+
attr_reader :code, :reason
|
36
|
+
|
37
|
+
def initialize(code, reason)
|
38
|
+
@code, @reason = code, reason
|
39
|
+
super "#{reason} (#{code})"
|
40
|
+
end
|
62
41
|
end
|
63
42
|
|
64
|
-
#
|
65
|
-
|
66
|
-
|
43
|
+
# Base class for host key exceptions. When rescuing this exception, you can
|
44
|
+
# inspect the key fingerprint and, if you want to proceed anyway, simply call
|
45
|
+
# the remember_host! method on the exception, and then retry.
|
46
|
+
class HostKeyError < Net::SSH::Exception
|
47
|
+
# the callback to use when #remember_host! is called
|
48
|
+
attr_writer :callback # :nodoc:
|
49
|
+
|
50
|
+
# situation-specific data describing the host (see #host, #port, etc.)
|
51
|
+
attr_writer :data # :nodoc:
|
52
|
+
|
53
|
+
# An accessor for getting at the data that was used to look up the host
|
54
|
+
# (see also #fingerprint, #host, #port, #ip, and #key).
|
55
|
+
def [](key)
|
56
|
+
@data && @data[key]
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns the fingerprint of the key for the host, which either was not
|
60
|
+
# found or did not match.
|
61
|
+
def fingerprint
|
62
|
+
@data && @data[:fingerprint]
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns the host name for the remote host, as reported by the socket.
|
66
|
+
def host
|
67
|
+
@data && @data[:peer] && @data[:peer][:host]
|
68
|
+
end
|
69
|
+
|
70
|
+
# Returns the port number for the remote host, as reported by the socket.
|
71
|
+
def port
|
72
|
+
@data && @data[:peer] && @data[:peer][:port]
|
73
|
+
end
|
74
|
+
|
75
|
+
# Returns the IP address of the remote host, as reported by the socket.
|
76
|
+
def ip
|
77
|
+
@data && @data[:peer] && @data[:peer][:ip]
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns the key itself, as reported by the remote host.
|
81
|
+
def key
|
82
|
+
@data && @data[:key]
|
83
|
+
end
|
84
|
+
|
85
|
+
# Tell Net::SSH to record this host and key in the known hosts file, so
|
86
|
+
# that subsequent connections will remember them.
|
87
|
+
def remember_host!
|
88
|
+
@callback.call
|
89
|
+
end
|
67
90
|
end
|
68
91
|
|
69
|
-
#
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
#
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
# Tell Net::SSH to record this host and key in the known hosts file, so
|
85
|
-
# that subsequent connections will remember them.
|
86
|
-
def remember_host!
|
87
|
-
@callback.call
|
88
|
-
end
|
92
|
+
# Raised when the cached key for a particular host does not match the
|
93
|
+
# key given by the host, which can be indicative of a man-in-the-middle
|
94
|
+
# attack. When rescuing this exception, you can inspect the key fingerprint
|
95
|
+
# and, if you want to proceed anyway, simply call the remember_host!
|
96
|
+
# method on the exception, and then retry.
|
97
|
+
class HostKeyMismatch < HostKeyError; end
|
98
|
+
|
99
|
+
# Raised when there is no cached key for a particular host, which probably
|
100
|
+
# means that the host has simply not been seen before.
|
101
|
+
# When rescuing this exception, you can inspect the key fingerprint and, if
|
102
|
+
# you want to proceed anyway, simply call the remember_host! method on the
|
103
|
+
# exception, and then retry.
|
104
|
+
class HostKeyUnknown < HostKeyError; end
|
89
105
|
end
|
90
|
-
|
91
|
-
# Raised when the cached key for a particular host does not match the
|
92
|
-
# key given by the host, which can be indicative of a man-in-the-middle
|
93
|
-
# attack. When rescuing this exception, you can inspect the key fingerprint
|
94
|
-
# and, if you want to proceed anyway, simply call the remember_host!
|
95
|
-
# method on the exception, and then retry.
|
96
|
-
class HostKeyMismatch < HostKeyError; end
|
97
|
-
|
98
|
-
# Raised when there is no cached key for a particular host, which probably
|
99
|
-
# means that the host has simply not been seen before.
|
100
|
-
# When rescuing this exception, you can inspect the key fingerprint and, if
|
101
|
-
# you want to proceed anyway, simply call the remember_host! method on the
|
102
|
-
# exception, and then retry.
|
103
|
-
class HostKeyUnknown < HostKeyError; end
|
104
|
-
end; end
|
106
|
+
end
|