summaryrefslogtreecommitdiff
path: root/lib/leap_cli/commands
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2017-01-10 10:45:36 -0800
committerelijah <elijah@riseup.net>2017-01-10 10:45:48 -0800
commitdd189d2de941ec081261ced814a9c822e5ef02a1 (patch)
tree7fe7a34735a80c29332ac76958a70fd55e173f8c /lib/leap_cli/commands
parent9b8314f3d2707a80e6238bb173280de291ecd2f4 (diff)
bugfix: `leap user ls` now warns if the ssh keytype is unsupported
Diffstat (limited to 'lib/leap_cli/commands')
-rw-r--r--lib/leap_cli/commands/user.rb24
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/leap_cli/commands/user.rb b/lib/leap_cli/commands/user.rb
index a10d5163..7fd5f52d 100644
--- a/lib/leap_cli/commands/user.rb
+++ b/lib/leap_cli/commands/user.rb
@@ -132,15 +132,21 @@ module LeapCli
log username, :color => :cyan do
log Path.relative_path(keyfile)
key = SSH::Key.load(keyfile)
- log 'SSH MD5 fingerprint: ' + key.fingerprint(:digest => :md5, :type => :ssh, :encoding => :hex)
- log 'SSH SHA256 fingerprint: ' + key.fingerprint(:digest => :sha256, :type => :ssh, :encoding => :base64)
- log 'DER MD5 fingerprint: ' + key.fingerprint(:digest => :md5, :type => :der, :encoding => :hex)
- if ssh_keys[key.fingerprint]
- log 'Matches local key: ' + ssh_keys[key.fingerprint].filename, color: :green
- if ssh_agent_keys[key.fingerprint]
- log 'Matches ssh-agent key: ' + ssh_agent_keys[key.fingerprint].summary(encoding: :base64), color: :green
- else
- log :error, 'No matching key in the ssh-agent'
+ if key.nil?
+ log :warning, "could not read ssh key #{keyfile}" do
+ log "currently, only these ssh key types are supported: " + SSH::Key::SUPPORTED_TYPES.join(", ")
+ end
+ else
+ log 'SSH MD5 fingerprint: ' + key.fingerprint(:digest => :md5, :type => :ssh, :encoding => :hex)
+ log 'SSH SHA256 fingerprint: ' + key.fingerprint(:digest => :sha256, :type => :ssh, :encoding => :base64)
+ log 'DER MD5 fingerprint: ' + key.fingerprint(:digest => :md5, :type => :der, :encoding => :hex)
+ if ssh_keys[key.fingerprint]
+ log 'Matches local key: ' + ssh_keys[key.fingerprint].filename, color: :green
+ if ssh_agent_keys[key.fingerprint]
+ log 'Matches ssh-agent key: ' + ssh_agent_keys[key.fingerprint].summary(encoding: :base64), color: :green
+ else
+ log :error, 'No matching key in the ssh-agent'
+ end
end
end
end