summaryrefslogtreecommitdiff
path: root/lib/leap_cli/ssh
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-12-19 15:23:57 -0800
committerelijah <elijah@riseup.net>2016-12-19 15:23:57 -0800
commite767aa460fc64a317551012f1781c2105c572158 (patch)
tree16bd29fbe46c971443427deafc12c64c9afdd9ee /lib/leap_cli/ssh
parent74f3f501aab17dc5d660af5d175c52bbcab5c5fe (diff)
feature: add troubleshooting info to `leap user ls`
It is hard to get ssh key setup right. This change makes it much easier to debug what the problem is.
Diffstat (limited to 'lib/leap_cli/ssh')
-rw-r--r--lib/leap_cli/ssh/key.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/leap_cli/ssh/key.rb b/lib/leap_cli/ssh/key.rb
index 76223b7e..108b6137 100644
--- a/lib/leap_cli/ssh/key.rb
+++ b/lib/leap_cli/ssh/key.rb
@@ -254,9 +254,9 @@ module LeapCli
end
if digest == "MD5" && encoding == :hex
- return fp.scan(/../).join(':')
+ return fp.strip.scan(/../).join(':')
else
- return fp
+ return fp.strip
end
end
@@ -267,11 +267,12 @@ module LeapCli
Net::SSH::Buffer.from(:key, @key).to_s.split("\001\000").last.size * 8
end
- def summary
+ def summary(type: :ssh, digest: :sha256, encoding: :hex)
+ fp = digest.to_s.upcase + ":" + self.fingerprint(type: type, digest: digest, encoding: encoding)
if self.filename
- "%s %s %s (%s)" % [self.type, self.bits, self.fingerprint, File.basename(self.filename)]
+ "%s %s %s (%s)" % [self.type, self.bits, fp, File.basename(self.filename)]
else
- "%s %s %s" % [self.type, self.bits, self.fingerprint]
+ "%s %s %s" % [self.type, self.bits, fp]
end
end