Skip to content

Commit 6f7d91f

Browse files
Andrii Sultanovlast-genius
authored andcommitted
CP-50411: Show all SSH host key fingerprints in xsconsole
Signed-off-by: Andrii Sultanov <[email protected]>
1 parent 1f9a211 commit 6f7d91f

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

XSConsoleData.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,22 @@ def Create(self):
148148
else:
149149
self.data['sslfingerprint'] = "<Unknown>"
150150

151-
try:
152-
self.data['sshfingerprint'] = ShellPipe('/usr/bin/ssh-keygen', '-lf', '/etc/ssh/ssh_host_rsa_key.pub').AllOutput()[0].split(' ')[1]
153-
except:
154-
self.data['sshfingerprint'] = Lang('<Unknown>')
151+
def get_ssh_key(filename):
152+
fingerprints = ShellPipe('/usr/bin/ssh-keygen', '-lf', filename).AllOutput()[0].split(' ')
153+
return fingerprints[1] + ' ' + fingerprints[-1]
154+
155+
keytypes = ['rsa', 'ed25519', 'ecdsa']
156+
fingerprints = []
157+
for keytype in keytypes:
158+
try:
159+
fingerprints.append(get_ssh_key('/etc/ssh/ssh_host_%s_key.pub' % keytype))
160+
except:
161+
pass
162+
163+
if not fingerprints:
164+
self.data['sshfingerprint'] = [Lang('<Unknown>')]
165+
else:
166+
self.data['sshfingerprint'] = fingerprints
155167

156168
try:
157169
self.data['state_on_usb_media'] = ( ShellPipe('/bin/bash', '-c', 'source /opt/xensource/libexec/oem-functions; if state_on_usb_media; then exit 1; else exit 0; fi').CallRC() != 0 )

plugins-base/XSFeatureStatus.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ def ActivateHandler(cls):
7575
message = ''
7676
message += Lang('Key fingerprint shown when connecting from '+appName+' (https)\n\n')
7777
message += data.sslfingerprint('')+'\n\n'
78-
message += Lang('Key fingerprint shown when logging in remotely (ssh)\n\n')
79-
message += data.sshfingerprint('')
78+
message += Lang('Key fingerprints shown when logging in remotely (ssh)\n\n')
79+
for fingerprint in data.sshfingerprint(''):
80+
message += fingerprint + '\n'
8081

8182
Layout.Inst().PushDialogue(InfoDialogue(Lang("SSL Key Fingerprints"), message))
8283

0 commit comments

Comments
 (0)