summaryrefslogtreecommitdiff
path: root/lib/net/ssh/key_factory.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/net/ssh/key_factory.rb')
-rw-r--r--lib/net/ssh/key_factory.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/net/ssh/key_factory.rb b/lib/net/ssh/key_factory.rb
index fdc7eda..94b4633 100644
--- a/lib/net/ssh/key_factory.rb
+++ b/lib/net/ssh/key_factory.rb
@@ -105,7 +105,13 @@ module Net; module SSH
# the file describes an RSA or DSA key, and will load it
# appropriately. The new public key is returned.
def load_data_public_key(data, filename="")
- _, blob = data.split(/ /)
+ fields = data.split(/ /)
+
+ blob = nil
+ begin
+ blob = fields.shift
+ end while !blob.nil? && !/^(ssh-(rsa|dss)|ecdsa-sha2-nistp\d+)$/.match(blob)
+ blob = fields.shift
raise Net::SSH::Exception, "public key at #{filename} is not valid" if blob.nil?