summaryrefslogtreecommitdiff
path: root/lib/net/ssh
diff options
context:
space:
mode:
authorMiklos Fazekas <mfazekas@szemafor.com>2016-12-11 12:58:32 +0100
committerMiklos Fazekas <mfazekas@szemafor.com>2016-12-11 12:58:32 +0100
commit3f4cb5f36eae11c29137f81e99f72b3b8e9c5940 (patch)
treef193403e59b40f1bc62b64bae56034223a291c68 /lib/net/ssh
parent3622f63edf1f34c4b9db020e57fe8c7cd15b340f (diff)
downloadnet-ssh-3f4cb5f36eae11c29137f81e99f72b3b8e9c5940.tar.gz
Use 1.9 hash syntax
Diffstat (limited to 'lib/net/ssh')
-rw-r--r--lib/net/ssh/authentication/key_manager.rb10
-rw-r--r--lib/net/ssh/config.rb2
-rw-r--r--lib/net/ssh/connection/channel.rb12
-rw-r--r--lib/net/ssh/key_factory.rb6
-rw-r--r--lib/net/ssh/proxy/http.rb10
-rw-r--r--lib/net/ssh/test.rb2
-rw-r--r--lib/net/ssh/test/kex.rb8
-rw-r--r--lib/net/ssh/transport/algorithms.rb86
-rw-r--r--lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb10
-rw-r--r--lib/net/ssh/transport/session.rb2
10 files changed, 74 insertions, 74 deletions
diff --git a/lib/net/ssh/authentication/key_manager.rb b/lib/net/ssh/authentication/key_manager.rb
index 31a613d..f324b7c 100644
--- a/lib/net/ssh/authentication/key_manager.rb
+++ b/lib/net/ssh/authentication/key_manager.rb
@@ -108,7 +108,7 @@ module Net
user_identities.delete(corresponding_user_identity) if corresponding_user_identity
if !options[:keys_only] || corresponding_user_identity
- known_identities[key] = { :from => :agent }
+ known_identities[key] = { from: :agent }
yield key
end
end
@@ -208,7 +208,7 @@ module Net
# Prepared identities from user key_data, preserving their order and sources.
def prepare_identities_from_data
key_data.map do |data|
- { :load_from => :data, :data => data }
+ { load_from: :data, data: data }
end
end
@@ -219,15 +219,15 @@ module Net
case identity[:load_from]
when :pubkey_file
key = KeyFactory.load_public_key(identity[:pubkey_file])
- { :public_key => key, :from => :file, :file => identity[:privkey_file] }
+ { public_key: key, from: :file, file: identity[:privkey_file] }
when :privkey_file
private_key = KeyFactory.load_private_key(identity[:privkey_file], options[:passphrase], ask_passphrase, options[:password_prompt])
key = private_key.send(:public_key)
- { :public_key => key, :from => :file, :file => identity[:privkey_file], :key => private_key }
+ { public_key: key, from: :file, file: identity[:privkey_file], key: private_key }
when :data
private_key = KeyFactory.load_data_private_key(identity[:data], options[:passphrase], ask_passphrase, "<key in memory>", options[:password_prompt])
key = private_key.send(:public_key)
- { :public_key => key, :from => :key_data, :data => identity[:data], :key => private_key }
+ { public_key: key, from: :key_data, data: identity[:data], key: private_key }
else
identity
end
diff --git a/lib/net/ssh/config.rb b/lib/net/ssh/config.rb
index 4a01e8b..4d8cf77 100644
--- a/lib/net/ssh/config.rb
+++ b/lib/net/ssh/config.rb
@@ -144,7 +144,7 @@ module Net; module SSH
def translate(settings)
auth_methods = default_auth_methods.clone
(auth_methods << 'challenge-response').uniq!
- ret = settings.inject({:auth_methods=>auth_methods}) do |hash, (key, value)|
+ ret = settings.inject({auth_methods: auth_methods}) do |hash, (key, value)|
case key
when 'bindaddress' then
hash[:bind_address] = value
diff --git a/lib/net/ssh/connection/channel.rb b/lib/net/ssh/connection/channel.rb
index f29affd..e3a2426 100644
--- a/lib/net/ssh/connection/channel.rb
+++ b/lib/net/ssh/connection/channel.rb
@@ -189,12 +189,12 @@ module Net; module SSH; module Connection
end
# A hash of the valid PTY options (see #request_pty).
- VALID_PTY_OPTIONS = { :term => "xterm",
- :chars_wide => 80,
- :chars_high => 24,
- :pixels_wide => 640,
- :pixels_high => 480,
- :modes => {} }
+ VALID_PTY_OPTIONS = { term: "xterm",
+ chars_wide: 80,
+ chars_high: 24,
+ pixels_wide: 640,
+ pixels_high: 480,
+ modes: {} }
# Requests that a pseudo-tty (or "pty") be made available for this channel.
# This is useful when you want to invoke and interact with some kind of
diff --git a/lib/net/ssh/key_factory.rb b/lib/net/ssh/key_factory.rb
index a830dbc..93ea6a6 100644
--- a/lib/net/ssh/key_factory.rb
+++ b/lib/net/ssh/key_factory.rb
@@ -37,7 +37,7 @@ module Net; module SSH
# whether the file describes an RSA or DSA key, and will load it
# appropriately. The new key is returned. If the key itself is
# encrypted (requiring a passphrase to use), the user will be
- # prompted to enter their password unless passphrase works.
+ # prompted to enter their password unless passphrase works.
def load_private_key(filename, passphrase=nil, ask_passphrase=true, prompt=Prompt.default)
data = File.read(File.expand_path(filename))
load_data_private_key(data, passphrase, ask_passphrase, filename, prompt)
@@ -47,7 +47,7 @@ module Net; module SSH
# whether the file describes an RSA or DSA key, and will load it
# appropriately. The new key is returned. If the key itself is
# encrypted (requiring a passphrase to use), the user will be
- # prompted to enter their password unless passphrase works.
+ # prompted to enter their password unless passphrase works.
def load_data_private_key(data, passphrase=nil, ask_passphrase=true, filename="", prompt=Prompt.default)
key_read, error_classes = classify_key(data, filename)
@@ -55,7 +55,7 @@ module Net; module SSH
tries = 0
prompter = nil
- result =
+ result =
begin
key_read[data, passphrase || 'invalid']
rescue *error_classes
diff --git a/lib/net/ssh/proxy/http.rb b/lib/net/ssh/proxy/http.rb
index 5d64173..49b1695 100644
--- a/lib/net/ssh/proxy/http.rb
+++ b/lib/net/ssh/proxy/http.rb
@@ -87,11 +87,11 @@ module Net; module SSH; module Proxy
body = socket.read(headers["Content-Length"].to_i)
end
- return { :version => version,
- :code => code.to_i,
- :reason => reason,
- :headers => headers,
- :body => body }
+ return { version: version,
+ code: code.to_i,
+ reason: reason,
+ headers: headers,
+ body: body }
end
end
diff --git a/lib/net/ssh/test.rb b/lib/net/ssh/test.rb
index 3e4677d..cd623a8 100644
--- a/lib/net/ssh/test.rb
+++ b/lib/net/ssh/test.rb
@@ -71,7 +71,7 @@ module Net; module SSH
# in these tests. It is a fully functional SSH transport session, operating
# over a mock socket (#socket).
def transport(options={})
- @transport ||= Net::SSH::Transport::Session.new(options[:host] || "localhost", options.merge(:kex => "test", :host_key => "ssh-rsa", :paranoid => false, :proxy => socket(options)))
+ @transport ||= Net::SSH::Transport::Session.new(options[:host] || "localhost", options.merge(kex: "test", host_key: "ssh-rsa", paranoid: false, proxy: socket(options)))
end
# First asserts that a story has been described (see #story). Then yields,
diff --git a/lib/net/ssh/test/kex.rb b/lib/net/ssh/test/kex.rb
index fc13095..0ed873f 100644
--- a/lib/net/ssh/test/kex.rb
+++ b/lib/net/ssh/test/kex.rb
@@ -31,10 +31,10 @@ module Net; module SSH; module Test
buffer = @connection.next_message
raise Net::SSH::Exception, "expected NEWKEYS" unless buffer.type == NEWKEYS
- { :session_id => "abc-xyz",
- :server_key => OpenSSL::PKey::RSA.new(512),
- :shared_secret => OpenSSL::BN.new("1234567890", 10),
- :hashing_algorithm => OpenSSL::Digest::SHA1 }
+ { session_id: "abc-xyz",
+ server_key: OpenSSL::PKey::RSA.new(512),
+ shared_secret: OpenSSL::BN.new("1234567890", 10),
+ hashing_algorithm: OpenSSL::Digest::SHA1 }
end
end
diff --git a/lib/net/ssh/transport/algorithms.rb b/lib/net/ssh/transport/algorithms.rb
index ae1a1dc..7e941a6 100644
--- a/lib/net/ssh/transport/algorithms.rb
+++ b/lib/net/ssh/transport/algorithms.rb
@@ -23,27 +23,27 @@ module Net; module SSH; module Transport
# Define the default algorithms, in order of preference, supported by
# Net::SSH.
ALGORITHMS = {
- :host_key => %w(ssh-rsa ssh-dss
- ssh-rsa-cert-v01@openssh.com
- ssh-rsa-cert-v00@openssh.com),
- :kex => %w(diffie-hellman-group-exchange-sha1
- diffie-hellman-group1-sha1
- diffie-hellman-group14-sha1
- diffie-hellman-group-exchange-sha256),
- :encryption => %w(aes128-cbc 3des-cbc blowfish-cbc cast128-cbc
- aes192-cbc aes256-cbc rijndael-cbc@lysator.liu.se
- idea-cbc none arcfour128 arcfour256 arcfour
- aes128-ctr aes192-ctr aes256-ctr
- cast128-ctr blowfish-ctr 3des-ctr
+ host_key: %w(ssh-rsa ssh-dss
+ ssh-rsa-cert-v01@openssh.com
+ ssh-rsa-cert-v00@openssh.com),
+ kex: %w(diffie-hellman-group-exchange-sha1
+ diffie-hellman-group1-sha1
+ diffie-hellman-group14-sha1
+ diffie-hellman-group-exchange-sha256),
+ encryption: %w(aes128-cbc 3des-cbc blowfish-cbc cast128-cbc
+ aes192-cbc aes256-cbc rijndael-cbc@lysator.liu.se
+ idea-cbc none arcfour128 arcfour256 arcfour
+ aes128-ctr aes192-ctr aes256-ctr
+ cast128-ctr blowfish-ctr 3des-ctr
),
- :hmac => %w(hmac-sha1 hmac-md5 hmac-sha1-96 hmac-md5-96
- hmac-ripemd160 hmac-ripemd160@openssh.com
- hmac-sha2-256 hmac-sha2-512 hmac-sha2-256-96
- hmac-sha2-512-96 none),
+ hmac: %w(hmac-sha1 hmac-md5 hmac-sha1-96 hmac-md5-96
+ hmac-ripemd160 hmac-ripemd160@openssh.com
+ hmac-sha2-256 hmac-sha2-512 hmac-sha2-256-96
+ hmac-sha2-512-96 none),
- :compression => %w(none zlib@openssh.com zlib),
- :language => %w()
+ compression: %w(none zlib@openssh.com zlib),
+ language: %w()
}
if defined?(OpenSSL::PKey::EC)
ALGORITHMS[:host_key] += %w(ecdsa-sha2-nistp256
@@ -255,7 +255,7 @@ module Net; module SSH; module Transport
# Parses a KEXINIT packet from the server.
def parse_server_algorithm_packet(packet)
- data = { :raw => packet.content }
+ data = { raw: packet.content }
packet.read(16) # skip the cookie value
@@ -356,13 +356,13 @@ module Net; module SSH; module Transport
debug { "exchanging keys" }
algorithm = Kex::MAP[kex].new(self, session,
- :client_version_string => Net::SSH::Transport::ServerVersion::PROTO_VERSION,
- :server_version_string => session.server_version.version,
- :server_algorithm_packet => @server_packet,
- :client_algorithm_packet => @client_packet,
- :need_bytes => kex_byte_requirement,
- :minimum_dh_bits => options[:minimum_dh_bits],
- :logger => logger)
+ client_version_string: Net::SSH::Transport::ServerVersion::PROTO_VERSION,
+ server_version_string: session.server_version.version,
+ server_algorithm_packet: @server_packet,
+ client_algorithm_packet: @client_packet,
+ need_bytes: kex_byte_requirement,
+ minimum_dh_bits: options[:minimum_dh_bits],
+ logger: logger)
result = algorithm.exchange_keys
secret = result[:shared_secret].to_ssh
@@ -372,7 +372,7 @@ module Net; module SSH; module Transport
@session_id ||= hash
key = Proc.new { |salt| digester.digest(secret + hash + salt + @session_id) }
-
+
iv_client = key["A"]
iv_server = key["B"]
key_client = key["C"]
@@ -380,26 +380,26 @@ module Net; module SSH; module Transport
mac_key_client = key["E"]
mac_key_server = key["F"]
- parameters = { :shared => secret, :hash => hash, :digester => digester }
-
- cipher_client = CipherFactory.get(encryption_client, parameters.merge(:iv => iv_client, :key => key_client, :encrypt => true))
- cipher_server = CipherFactory.get(encryption_server, parameters.merge(:iv => iv_server, :key => key_server, :decrypt => true))
+ parameters = { shared: secret, hash: hash, digester: digester }
+
+ cipher_client = CipherFactory.get(encryption_client, parameters.merge(iv: iv_client, key: key_client, encrypt: true))
+ cipher_server = CipherFactory.get(encryption_server, parameters.merge(iv: iv_server, key: key_server, decrypt: true))
mac_client = HMAC.get(hmac_client, mac_key_client, parameters)
mac_server = HMAC.get(hmac_server, mac_key_server, parameters)
- session.configure_client :cipher => cipher_client, :hmac => mac_client,
- :compression => normalize_compression_name(compression_client),
- :compression_level => options[:compression_level],
- :rekey_limit => options[:rekey_limit],
- :max_packets => options[:rekey_packet_limit],
- :max_blocks => options[:rekey_blocks_limit]
-
- session.configure_server :cipher => cipher_server, :hmac => mac_server,
- :compression => normalize_compression_name(compression_server),
- :rekey_limit => options[:rekey_limit],
- :max_packets => options[:rekey_packet_limit],
- :max_blocks => options[:rekey_blocks_limit]
+ session.configure_client cipher: cipher_client, hmac: mac_client,
+ compression: normalize_compression_name(compression_client),
+ compression_level: options[:compression_level],
+ rekey_limit: options[:rekey_limit],
+ max_packets: options[:rekey_packet_limit],
+ max_blocks: options[:rekey_blocks_limit]
+
+ session.configure_server cipher: cipher_server, hmac: mac_server,
+ compression: normalize_compression_name(compression_server),
+ rekey_limit: options[:rekey_limit],
+ max_packets: options[:rekey_packet_limit],
+ max_blocks: options[:rekey_blocks_limit]
@initialized = true
end
diff --git a/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb b/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb
index 7379e01..8c808d3 100644
--- a/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb
+++ b/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb
@@ -69,10 +69,10 @@ module Net; module SSH; module Transport; module Kex
session_id = verify_signature(result)
confirm_newkeys
- return { :session_id => session_id,
- :server_key => result[:server_key],
- :shared_secret => result[:shared_secret],
- :hashing_algorithm => digester }
+ return { session_id: session_id,
+ server_key: result[:server_key],
+ shared_secret: result[:shared_secret],
+ hashing_algorithm: digester }
end
private
@@ -170,7 +170,7 @@ module Net; module SSH; module Transport; module Kex
blob, fingerprint = generate_key_fingerprint(key)
- unless connection.host_key_verifier.verify(:key => key, :key_blob => blob, :fingerprint => fingerprint, :session => connection)
+ unless connection.host_key_verifier.verify(key: key, key_blob: blob, fingerprint: fingerprint, session: connection)
raise Net::SSH::Exception, "host key verification failed"
end
end
diff --git a/lib/net/ssh/transport/session.rb b/lib/net/ssh/transport/session.rb
index f4905a6..cb9a3cc 100644
--- a/lib/net/ssh/transport/session.rb
+++ b/lib/net/ssh/transport/session.rb
@@ -164,7 +164,7 @@ module Net; module SSH; module Transport
# Returns a hash of information about the peer (remote) side of the socket,
# including :ip, :port, :host, and :canonized (see #host_as_string).
def peer
- @peer ||= { :ip => socket.peer_ip, :port => @port.to_i, :host => @host, :canonized => host_as_string }
+ @peer ||= { ip: socket.peer_ip, port: @port.to_i, host: @host, canonized: host_as_string }
end
# Blocks until a new packet is available to be read, and returns that