hrr_rb_ssh 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/demo/server.rb +13 -1
- data/lib/hrr_rb_ssh/authentication/method/none/context.rb +1 -1
- data/lib/hrr_rb_ssh/authentication/method/none.rb +4 -4
- data/lib/hrr_rb_ssh/authentication/method/password/context.rb +1 -1
- data/lib/hrr_rb_ssh/authentication/method/password.rb +4 -4
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/codable.rb +5 -5
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss.rb +29 -18
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa.rb +27 -16
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm.rb +7 -13
- data/lib/hrr_rb_ssh/authentication/method/publickey/context.rb +1 -1
- data/lib/hrr_rb_ssh/authentication/method/publickey.rb +5 -5
- data/lib/hrr_rb_ssh/authentication/method.rb +6 -12
- data/lib/hrr_rb_ssh/authentication.rb +1 -1
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env/context.rb +2 -2
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env.rb +2 -3
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec/context.rb +2 -2
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec.rb +2 -3
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req/context.rb +2 -2
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req.rb +2 -3
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell/context.rb +2 -2
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell.rb +2 -3
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem/context.rb +2 -2
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem.rb +2 -3
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type.rb +16 -11
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session.rb +1 -15
- data/lib/hrr_rb_ssh/connection/channel/channel_type.rb +15 -10
- data/lib/hrr_rb_ssh/connection/channel.rb +1 -1
- data/lib/hrr_rb_ssh/data_type.rb +153 -0
- data/lib/hrr_rb_ssh/message/001_ssh_msg_disconnect.rb +6 -6
- data/lib/hrr_rb_ssh/message/002_ssh_msg_ignore.rb +4 -4
- data/lib/hrr_rb_ssh/message/003_ssh_msg_unimplemented.rb +4 -4
- data/lib/hrr_rb_ssh/message/004_ssh_msg_debug.rb +6 -6
- data/lib/hrr_rb_ssh/message/005_ssh_msg_service_request.rb +4 -4
- data/lib/hrr_rb_ssh/message/006_ssh_msg_service_accept.rb +4 -4
- data/lib/hrr_rb_ssh/message/020_ssh_msg_kexinit.rb +31 -31
- data/lib/hrr_rb_ssh/message/021_ssh_msg_newkeys.rb +3 -3
- data/lib/hrr_rb_ssh/message/030_ssh_msg_kexdh_init.rb +4 -4
- data/lib/hrr_rb_ssh/message/031_ssh_msg_kexdh_reply.rb +6 -6
- data/lib/hrr_rb_ssh/message/050_ssh_msg_userauth_request.rb +18 -18
- data/lib/hrr_rb_ssh/message/051_ssh_msg_userauth_failure.rb +5 -5
- data/lib/hrr_rb_ssh/message/052_ssh_msg_userauth_success.rb +3 -3
- data/lib/hrr_rb_ssh/message/060_ssh_msg_userauth_pk_ok.rb +5 -5
- data/lib/hrr_rb_ssh/message/080_ssh_msg_global_request.rb +13 -13
- data/lib/hrr_rb_ssh/message/081_ssh_msg_request_success.rb +6 -6
- data/lib/hrr_rb_ssh/message/082_ssh_msg_request_failure.rb +3 -3
- data/lib/hrr_rb_ssh/message/090_ssh_msg_channel_open.rb +25 -25
- data/lib/hrr_rb_ssh/message/091_ssh_msg_channel_open_confirmation.rb +25 -25
- data/lib/hrr_rb_ssh/message/092_ssh_msg_channel_open_failure.rb +7 -7
- data/lib/hrr_rb_ssh/message/093_ssh_msg_channel_window_adjust.rb +5 -5
- data/lib/hrr_rb_ssh/message/094_ssh_msg_channel_data.rb +5 -5
- data/lib/hrr_rb_ssh/message/095_ssh_msg_channel_extended_data.rb +6 -6
- data/lib/hrr_rb_ssh/message/096_ssh_msg_channel_eof.rb +4 -4
- data/lib/hrr_rb_ssh/message/097_ssh_msg_channel_close.rb +4 -4
- data/lib/hrr_rb_ssh/message/098_ssh_msg_channel_request.rb +53 -53
- data/lib/hrr_rb_ssh/message/099_ssh_msg_channel_success.rb +4 -4
- data/lib/hrr_rb_ssh/message/100_ssh_msg_channel_failure.rb +4 -4
- data/lib/hrr_rb_ssh/message/codable.rb +2 -3
- data/lib/hrr_rb_ssh/subclass_with_preference_listable.rb +29 -0
- data/lib/hrr_rb_ssh/transport/compression_algorithm/functionable.rb +4 -4
- data/lib/hrr_rb_ssh/transport/compression_algorithm/none.rb +1 -6
- data/lib/hrr_rb_ssh/transport/compression_algorithm/unfunctionable.rb +4 -0
- data/lib/hrr_rb_ssh/transport/compression_algorithm/zlib.rb +1 -6
- data/lib/hrr_rb_ssh/transport/compression_algorithm.rb +5 -11
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes128_cbc.rb +1 -2
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes128_ctr.rb +1 -2
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes192_cbc.rb +1 -2
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes192_ctr.rb +1 -2
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes256_cbc.rb +1 -2
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes256_ctr.rb +1 -2
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/arcfour.rb +1 -2
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/blowfish_cbc.rb +1 -2
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/cast128_cbc.rb +1 -2
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/functionable.rb +1 -2
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/none.rb +1 -6
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/three_des_cbc.rb +1 -2
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/unfunctionable.rb +6 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm.rb +5 -11
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman.rb +14 -14
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group14_sha1.rb +2 -5
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group1_sha1.rb +2 -5
- data/lib/hrr_rb_ssh/transport/kex_algorithm.rb +5 -10
- data/lib/hrr_rb_ssh/transport/mac_algorithm/functionable.rb +2 -3
- data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_md5.rb +3 -5
- data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_md5_96.rb +3 -5
- data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_sha1.rb +3 -5
- data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_sha1_96.rb +3 -5
- data/lib/hrr_rb_ssh/transport/mac_algorithm/none.rb +2 -8
- data/lib/hrr_rb_ssh/transport/mac_algorithm/unfunctionable.rb +4 -0
- data/lib/hrr_rb_ssh/transport/mac_algorithm.rb +5 -11
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss.rb +14 -13
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa.rb +12 -11
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm.rb +5 -10
- data/lib/hrr_rb_ssh/transport.rb +147 -108
- data/lib/hrr_rb_ssh/version.rb +1 -1
- metadata +4 -12
- data/lib/hrr_rb_ssh/authentication/method/method.rb +0 -34
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/algorithm.rb +0 -41
- data/lib/hrr_rb_ssh/connection/channel/channel_type/channel_type.rb +0 -30
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/request_type.rb +0 -34
- data/lib/hrr_rb_ssh/transport/compression_algorithm/compression_algorithm.rb +0 -34
- data/lib/hrr_rb_ssh/transport/data_type.rb +0 -163
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm.rb +0 -34
- data/lib/hrr_rb_ssh/transport/kex_algorithm/kex_algorithm.rb +0 -34
- data/lib/hrr_rb_ssh/transport/mac_algorithm/mac_algorithm.rb +0 -34
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/server_host_key_algorithm.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ca801bcbdd5c4d01bbdfdd2827f114771d5e8e2f5b709a66313c1d36a5154fb
|
4
|
+
data.tar.gz: 630ce9b5a4983a2f7aa72239504821c43f26c6527857bb0709c1daa60b431c4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6db961156a157f29a616dfa75320c394baf86ad78e85fa7b9ec7676ea76d23f10ce1b71b6ecfbb3d181f913b6af86dd713e660f4fb9fa69e98b5b5465ec902f
|
7
|
+
data.tar.gz: 1efb26c747d9360359aa04c8d12a88ff83b95ab53d4d8d04262f368459c1b016f0e8f653f88042e5aeebdb0f436d430da5f5a3431b4f47c1c79b6be6033dc32a
|
data/demo/server.rb
CHANGED
@@ -18,6 +18,12 @@ logger.level = Logger::INFO
|
|
18
18
|
HrrRbSsh::Logger.initialize logger
|
19
19
|
|
20
20
|
|
21
|
+
tran_preferred_encryption_algorithms = %w(aes128-ctr aes192-ctr aes256-ctr aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc aes256-cbc arcfour)
|
22
|
+
tran_preferred_server_host_key_algorithms = %w(ssh-rsa ssh-dss)
|
23
|
+
tran_preferred_kex_algorithms = %w(diffie-hellman-group14-sha1 diffie-hellman-group1-sha1)
|
24
|
+
tran_preferred_mac_algorithms = %w(hmac-sha1 hmac-md5 hmac-sha1-96 hmac-md5-96)
|
25
|
+
tran_preferred_compression_algorithms = %w(none zlib)
|
26
|
+
|
21
27
|
auth_none = HrrRbSsh::Authentication::Authenticator.new { |context|
|
22
28
|
false
|
23
29
|
}
|
@@ -163,6 +169,12 @@ conn_exec = HrrRbSsh::Connection::RequestHandler.new { |context|
|
|
163
169
|
|
164
170
|
options = {}
|
165
171
|
|
172
|
+
options['transport_preferred_encryption_algorithms'] = tran_preferred_encryption_algorithms
|
173
|
+
options['transport_preferred_server_host_key_algorithms'] = tran_preferred_server_host_key_algorithms
|
174
|
+
options['transport_preferred_kex_algorithms'] = tran_preferred_kex_algorithms
|
175
|
+
options['transport_preferred_mac_algorithms'] = tran_preferred_mac_algorithms
|
176
|
+
options['transport_preferred_compression_algorithms'] = tran_preferred_compression_algorithms
|
177
|
+
|
166
178
|
options['authentication_none_authenticator'] = auth_none
|
167
179
|
options['authentication_publickey_authenticator'] = auth_publickey
|
168
180
|
options['authentication_password_authenticator'] = auth_password
|
@@ -176,7 +188,7 @@ options['connection_channel_request_exec'] = conn_exec
|
|
176
188
|
server = TCPServer.new 10022
|
177
189
|
while true
|
178
190
|
t = Thread.new(server.accept) do |io|
|
179
|
-
tran = HrrRbSsh::Transport.new io, HrrRbSsh::Transport::Mode::SERVER
|
191
|
+
tran = HrrRbSsh::Transport.new io, HrrRbSsh::Transport::Mode::SERVER, options
|
180
192
|
auth = HrrRbSsh::Authentication.new tran, options
|
181
193
|
conn = HrrRbSsh::Connection.new auth, options
|
182
194
|
conn.start
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/
|
4
|
+
require 'hrr_rb_ssh/logger'
|
5
5
|
|
6
6
|
module HrrRbSsh
|
7
7
|
class Authentication
|
8
|
-
|
8
|
+
class Method
|
9
9
|
class None < Method
|
10
10
|
NAME = 'none'
|
11
|
+
PREFERENCE = 0
|
11
12
|
|
12
13
|
def initialize options
|
13
|
-
|
14
|
-
|
14
|
+
@logger = HrrRbSsh::Logger.new(self.class.name)
|
15
15
|
@authenticator = options.fetch( 'authentication_none_authenticator', Authenticator.new { false } )
|
16
16
|
end
|
17
17
|
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/
|
4
|
+
require 'hrr_rb_ssh/logger'
|
5
5
|
|
6
6
|
module HrrRbSsh
|
7
7
|
class Authentication
|
8
|
-
|
8
|
+
class Method
|
9
9
|
class Password < Method
|
10
10
|
NAME = 'password'
|
11
|
+
PREFERENCE = 10
|
11
12
|
|
12
13
|
def initialize options
|
13
|
-
|
14
|
-
|
14
|
+
@logger = HrrRbSsh::Logger.new(self.class.name)
|
15
15
|
@authenticator = options.fetch( 'authentication_password_authenticator', Authenticator.new { false } )
|
16
16
|
end
|
17
17
|
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/
|
4
|
+
require 'hrr_rb_ssh/data_type'
|
5
5
|
|
6
6
|
module HrrRbSsh
|
7
7
|
class Authentication
|
8
|
-
|
8
|
+
class Method
|
9
9
|
class Publickey
|
10
|
-
|
10
|
+
class Algorithm
|
11
11
|
module Codable
|
12
12
|
def encode definition, payload
|
13
13
|
definition.map{ |data_type, field_name|
|
14
14
|
field_value = if payload[field_name].instance_of? ::Proc then payload[field_name].call else payload[field_name] end
|
15
|
-
|
15
|
+
data_type.encode(field_value)
|
16
16
|
}.join
|
17
17
|
end
|
18
18
|
|
@@ -21,7 +21,7 @@ module HrrRbSsh
|
|
21
21
|
definition.map{ |data_type, field_name|
|
22
22
|
[
|
23
23
|
field_name,
|
24
|
-
|
24
|
+
data_type.decode(payload_io)
|
25
25
|
]
|
26
26
|
}.to_h
|
27
27
|
end
|
@@ -1,39 +1,50 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
+
require 'hrr_rb_ssh/logger'
|
5
|
+
require 'hrr_rb_ssh/data_type'
|
6
|
+
require 'hrr_rb_ssh/authentication/method/publickey/algorithm/codable'
|
7
|
+
|
4
8
|
module HrrRbSsh
|
5
9
|
class Authentication
|
6
|
-
|
10
|
+
class Method
|
7
11
|
class Publickey
|
8
|
-
|
12
|
+
class Algorithm
|
9
13
|
class SshDss < Algorithm
|
10
|
-
NAME
|
14
|
+
NAME = 'ssh-dss'
|
15
|
+
PREFERENCE = 10
|
11
16
|
DIGEST = 'sha1'
|
12
17
|
|
13
18
|
PUBLIC_KEY_BLOB_DEFINITION = [
|
14
|
-
[
|
15
|
-
[
|
16
|
-
[
|
17
|
-
[
|
18
|
-
[
|
19
|
+
[DataType::String, 'public key algorithm name'],
|
20
|
+
[DataType::Mpint, 'p'],
|
21
|
+
[DataType::Mpint, 'q'],
|
22
|
+
[DataType::Mpint, 'g'],
|
23
|
+
[DataType::Mpint, 'y'],
|
19
24
|
]
|
20
25
|
|
21
26
|
SIGNATURE_DEFINITION = [
|
22
|
-
[
|
23
|
-
[
|
27
|
+
[DataType::String, 'public key algorithm name'],
|
28
|
+
[DataType::String, 'signature blob'],
|
24
29
|
]
|
25
30
|
|
26
31
|
SIGNATURE_BLOB_DEFINITION = [
|
27
|
-
[
|
28
|
-
[
|
29
|
-
[
|
30
|
-
[
|
31
|
-
[
|
32
|
-
[
|
33
|
-
[
|
34
|
-
[
|
32
|
+
[DataType::String, 'session identifier'],
|
33
|
+
[DataType::Byte, 'message number'],
|
34
|
+
[DataType::String, 'user name'],
|
35
|
+
[DataType::String, 'service name'],
|
36
|
+
[DataType::String, 'method name'],
|
37
|
+
[DataType::Boolean, 'with signature'],
|
38
|
+
[DataType::String, 'public key algorithm name'],
|
39
|
+
[DataType::String, 'public key blob'],
|
35
40
|
]
|
36
41
|
|
42
|
+
include Codable
|
43
|
+
|
44
|
+
def initialize
|
45
|
+
@logger = HrrRbSsh::Logger.new(self.class.name)
|
46
|
+
end
|
47
|
+
|
37
48
|
def verify_public_key public_key_algorithm_name, public_key, public_key_blob
|
38
49
|
public_key = case public_key
|
39
50
|
when String
|
@@ -1,37 +1,48 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
+
require 'hrr_rb_ssh/logger'
|
5
|
+
require 'hrr_rb_ssh/data_type'
|
6
|
+
require 'hrr_rb_ssh/authentication/method/publickey/algorithm/codable'
|
7
|
+
|
4
8
|
module HrrRbSsh
|
5
9
|
class Authentication
|
6
|
-
|
10
|
+
class Method
|
7
11
|
class Publickey
|
8
|
-
|
12
|
+
class Algorithm
|
9
13
|
class SshRsa < Algorithm
|
10
|
-
NAME
|
14
|
+
NAME = 'ssh-rsa'
|
15
|
+
PREFERENCE = 20
|
11
16
|
DIGEST = 'sha1'
|
12
17
|
|
13
18
|
PUBLIC_KEY_BLOB_DEFINITION = [
|
14
|
-
[
|
15
|
-
[
|
16
|
-
[
|
19
|
+
[DataType::String, 'public key algorithm name'],
|
20
|
+
[DataType::Mpint, 'e'],
|
21
|
+
[DataType::Mpint, 'n'],
|
17
22
|
]
|
18
23
|
|
19
24
|
SIGNATURE_DEFINITION = [
|
20
|
-
[
|
21
|
-
[
|
25
|
+
[DataType::String, 'public key algorithm name'],
|
26
|
+
[DataType::String, 'signature blob'],
|
22
27
|
]
|
23
28
|
|
24
29
|
SIGNATURE_BLOB_DEFINITION = [
|
25
|
-
[
|
26
|
-
[
|
27
|
-
[
|
28
|
-
[
|
29
|
-
[
|
30
|
-
[
|
31
|
-
[
|
32
|
-
[
|
30
|
+
[DataType::String, 'session identifier'],
|
31
|
+
[DataType::Byte, 'message number'],
|
32
|
+
[DataType::String, 'user name'],
|
33
|
+
[DataType::String, 'service name'],
|
34
|
+
[DataType::String, 'method name'],
|
35
|
+
[DataType::Boolean, 'with signature'],
|
36
|
+
[DataType::String, 'public key algorithm name'],
|
37
|
+
[DataType::String, 'public key blob'],
|
33
38
|
]
|
34
39
|
|
40
|
+
include Codable
|
41
|
+
|
42
|
+
def initialize
|
43
|
+
@logger = HrrRbSsh::Logger.new(self.class.name)
|
44
|
+
end
|
45
|
+
|
35
46
|
def verify_public_key public_key_algorithm_name, public_key, public_key_blob
|
36
47
|
public_key = case public_key
|
37
48
|
when String
|
@@ -1,21 +1,16 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
+
require 'hrr_rb_ssh/subclass_with_preference_listable'
|
5
|
+
|
4
6
|
module HrrRbSsh
|
5
7
|
class Authentication
|
6
|
-
|
8
|
+
class Method
|
7
9
|
class Publickey
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def self.name_list
|
14
|
-
Algorithm.name_list
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.[] key
|
18
|
-
Algorithm[key]
|
10
|
+
class Algorithm
|
11
|
+
@subclass_list = Array.new
|
12
|
+
class << self
|
13
|
+
include SubclassWithPreferenceListable
|
19
14
|
end
|
20
15
|
end
|
21
16
|
end
|
@@ -23,6 +18,5 @@ module HrrRbSsh
|
|
23
18
|
end
|
24
19
|
end
|
25
20
|
|
26
|
-
require 'hrr_rb_ssh/authentication/method/publickey/algorithm/algorithm'
|
27
21
|
require 'hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss'
|
28
22
|
require 'hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa'
|
@@ -1,24 +1,24 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/
|
4
|
+
require 'hrr_rb_ssh/logger'
|
5
5
|
|
6
6
|
module HrrRbSsh
|
7
7
|
class Authentication
|
8
|
-
|
8
|
+
class Method
|
9
9
|
class Publickey < Method
|
10
10
|
NAME = 'publickey'
|
11
|
+
PREFERENCE = 20
|
11
12
|
|
12
13
|
def initialize options
|
13
|
-
|
14
|
-
|
14
|
+
@logger = HrrRbSsh::Logger.new(self.class.name)
|
15
15
|
@session_id = options['session id']
|
16
16
|
@authenticator = options.fetch( 'authentication_publickey_authenticator', Authenticator.new { false } )
|
17
17
|
end
|
18
18
|
|
19
19
|
def authenticate userauth_request_message
|
20
20
|
public_key_algorithm_name = userauth_request_message['public key algorithm name']
|
21
|
-
unless Algorithm.
|
21
|
+
unless Algorithm.list_preferred.include?(public_key_algorithm_name)
|
22
22
|
@logger.info("unsupported public key algorithm: #{public_key_algorithm_name}")
|
23
23
|
return false
|
24
24
|
end
|
@@ -1,25 +1,19 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
+
require 'hrr_rb_ssh/subclass_with_preference_listable'
|
5
|
+
|
4
6
|
module HrrRbSsh
|
5
7
|
class Authentication
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def self.name_list
|
12
|
-
Method.name_list
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.[] key
|
16
|
-
Method[key]
|
8
|
+
class Method
|
9
|
+
@subclass_list = Array.new
|
10
|
+
class << self
|
11
|
+
include SubclassWithPreferenceListable
|
17
12
|
end
|
18
13
|
end
|
19
14
|
end
|
20
15
|
end
|
21
16
|
|
22
|
-
require 'hrr_rb_ssh/authentication/method/method'
|
23
17
|
require 'hrr_rb_ssh/authentication/method/none'
|
24
18
|
require 'hrr_rb_ssh/authentication/method/password'
|
25
19
|
require 'hrr_rb_ssh/authentication/method/publickey'
|
@@ -95,7 +95,7 @@ module HrrRbSsh
|
|
95
95
|
def send_userauth_failure
|
96
96
|
message = {
|
97
97
|
'message number' => HrrRbSsh::Message::SSH_MSG_USERAUTH_FAILURE::VALUE,
|
98
|
-
'authentications that can continue' => Method.
|
98
|
+
'authentications that can continue' => Method.list_preferred,
|
99
99
|
'partial success' => false,
|
100
100
|
}
|
101
101
|
payload = HrrRbSsh::Message::SSH_MSG_USERAUTH_FAILURE.encode message
|
@@ -3,14 +3,13 @@
|
|
3
3
|
|
4
4
|
require 'hrr_rb_ssh/logger'
|
5
5
|
require 'hrr_rb_ssh/connection/request_handler'
|
6
|
-
require 'hrr_rb_ssh/connection/channel/channel_type/session/request_type/request_type'
|
7
6
|
|
8
7
|
module HrrRbSsh
|
9
8
|
class Connection
|
10
9
|
class Channel
|
11
|
-
|
10
|
+
class ChannelType
|
12
11
|
class Session
|
13
|
-
|
12
|
+
class RequestType
|
14
13
|
class Env < RequestType
|
15
14
|
NAME = 'env'
|
16
15
|
|
@@ -3,14 +3,13 @@
|
|
3
3
|
|
4
4
|
require 'hrr_rb_ssh/logger'
|
5
5
|
require 'hrr_rb_ssh/connection/request_handler'
|
6
|
-
require 'hrr_rb_ssh/connection/channel/channel_type/session/request_type/request_type'
|
7
6
|
|
8
7
|
module HrrRbSsh
|
9
8
|
class Connection
|
10
9
|
class Channel
|
11
|
-
|
10
|
+
class ChannelType
|
12
11
|
class Session
|
13
|
-
|
12
|
+
class RequestType
|
14
13
|
class Exec < RequestType
|
15
14
|
NAME = 'exec'
|
16
15
|
|
@@ -3,14 +3,13 @@
|
|
3
3
|
|
4
4
|
require 'hrr_rb_ssh/logger'
|
5
5
|
require 'hrr_rb_ssh/connection/request_handler'
|
6
|
-
require 'hrr_rb_ssh/connection/channel/channel_type/session/request_type/request_type'
|
7
6
|
|
8
7
|
module HrrRbSsh
|
9
8
|
class Connection
|
10
9
|
class Channel
|
11
|
-
|
10
|
+
class ChannelType
|
12
11
|
class Session
|
13
|
-
|
12
|
+
class RequestType
|
14
13
|
class PtyReq < RequestType
|
15
14
|
NAME = 'pty-req'
|
16
15
|
|
@@ -3,14 +3,13 @@
|
|
3
3
|
|
4
4
|
require 'hrr_rb_ssh/logger'
|
5
5
|
require 'hrr_rb_ssh/connection/request_handler'
|
6
|
-
require 'hrr_rb_ssh/connection/channel/channel_type/session/request_type/request_type'
|
7
6
|
|
8
7
|
module HrrRbSsh
|
9
8
|
class Connection
|
10
9
|
class Channel
|
11
|
-
|
10
|
+
class ChannelType
|
12
11
|
class Session
|
13
|
-
|
12
|
+
class RequestType
|
14
13
|
class Shell < RequestType
|
15
14
|
NAME = 'shell'
|
16
15
|
|
@@ -3,14 +3,13 @@
|
|
3
3
|
|
4
4
|
require 'hrr_rb_ssh/logger'
|
5
5
|
require 'hrr_rb_ssh/connection/request_handler'
|
6
|
-
require 'hrr_rb_ssh/connection/channel/channel_type/session/request_type/request_type'
|
7
6
|
|
8
7
|
module HrrRbSsh
|
9
8
|
class Connection
|
10
9
|
class Channel
|
11
|
-
|
10
|
+
class ChannelType
|
12
11
|
class Session
|
13
|
-
|
12
|
+
class RequestType
|
14
13
|
class Subsystem < RequestType
|
15
14
|
NAME = 'subsystem'
|
16
15
|
|
@@ -4,19 +4,25 @@
|
|
4
4
|
module HrrRbSsh
|
5
5
|
class Connection
|
6
6
|
class Channel
|
7
|
-
|
7
|
+
class ChannelType
|
8
8
|
class Session
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
class RequestType
|
10
|
+
@subclass_list = Array.new
|
11
|
+
class << self
|
12
|
+
def inherited klass
|
13
|
+
@subclass_list.push klass if @subclass_list
|
14
|
+
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
def [] key
|
17
|
+
__subclass_list__(__method__).find{ |klass| klass::NAME == key }
|
18
|
+
end
|
19
|
+
|
20
|
+
def __subclass_list__ method_name
|
21
|
+
send(:method_missing, method_name) unless @subclass_list
|
22
|
+
@subclass_list
|
23
|
+
end
|
17
24
|
|
18
|
-
|
19
|
-
RequestType[key]
|
25
|
+
private :__subclass_list__
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -25,7 +31,6 @@ module HrrRbSsh
|
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
28
|
-
require 'hrr_rb_ssh/connection/channel/channel_type/session/request_type/request_type'
|
29
34
|
require 'hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req'
|
30
35
|
require 'hrr_rb_ssh/connection/channel/channel_type/session/request_type/env'
|
31
36
|
require 'hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell'
|
@@ -1,26 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/connection/channel/channel_type/channel_type'
|
5
|
-
|
6
4
|
module HrrRbSsh
|
7
5
|
class Connection
|
8
6
|
class Channel
|
9
|
-
|
7
|
+
class ChannelType
|
10
8
|
class Session < ChannelType
|
11
9
|
NAME = 'session'
|
12
|
-
|
13
|
-
def self.list
|
14
|
-
RequestType.list
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.name_list
|
18
|
-
RequestType.name_list
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.[] key
|
22
|
-
RequestType[key]
|
23
|
-
end
|
24
10
|
end
|
25
11
|
end
|
26
12
|
end
|