From 09ddd1f8b5103f8eba5145f224f89d835f5ebc01 Mon Sep 17 00:00:00 2001 From: cfs4819 Date: Fri, 22 Mar 2024 14:36:06 +0800 Subject: [PATCH 1/4] Fix SSH X11 Repeated Handshake Issue --- tabby-ssh/src/session/ssh.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tabby-ssh/src/session/ssh.ts b/tabby-ssh/src/session/ssh.ts index 6bc354ef97..d28e576db3 100644 --- a/tabby-ssh/src/session/ssh.ts +++ b/tabby-ssh/src/session/ssh.ts @@ -205,10 +205,22 @@ export class SSHSession { } const hostVerifiedPromise: Promise = new Promise((resolve, reject) => { + let hostkey_old: string | undefined + let isKeyVerified: boolean = false ssh.on('handshake', async handshake => { - if (!await this.verifyHostKey(handshake)) { - this.ssh.end() - reject(new Error('Host key verification failed')) + if (isKeyVerified) { + resolve() + return + } + if (hostkey_old !== handshake.serverHostKey) { + hostkey_old = handshake.serverHostKey + if (!await this.verifyHostKey(handshake)) { + this.ssh.end() + reject(new Error('Host key verification failed')) + isKeyVerified = false + }else { + isKeyVerified = true + } } this.logger.info('Handshake complete:', handshake) resolve() From 31e35541cee5b1a7e6a0286ee807e3276c67c78b Mon Sep 17 00:00:00 2001 From: cfs4819 Date: Fri, 22 Mar 2024 14:57:28 +0800 Subject: [PATCH 2/4] Fix SSH X11 Repeated Handshake Issue --- tabby-ssh/src/session/ssh.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabby-ssh/src/session/ssh.ts b/tabby-ssh/src/session/ssh.ts index d28e576db3..8d996429e1 100644 --- a/tabby-ssh/src/session/ssh.ts +++ b/tabby-ssh/src/session/ssh.ts @@ -205,7 +205,7 @@ export class SSHSession { } const hostVerifiedPromise: Promise = new Promise((resolve, reject) => { - let hostkey_old: string | undefined + let hostkey_old: string = '' let isKeyVerified: boolean = false ssh.on('handshake', async handshake => { if (isKeyVerified) { From 10c974f272007e9673d426c7dc15f746910fe6e5 Mon Sep 17 00:00:00 2001 From: cfs4819 Date: Fri, 22 Mar 2024 15:00:47 +0800 Subject: [PATCH 3/4] Fix SSH X11 Repeated Handshake Issue --- tabby-ssh/src/session/ssh.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tabby-ssh/src/session/ssh.ts b/tabby-ssh/src/session/ssh.ts index 8d996429e1..742dece765 100644 --- a/tabby-ssh/src/session/ssh.ts +++ b/tabby-ssh/src/session/ssh.ts @@ -205,8 +205,8 @@ export class SSHSession { } const hostVerifiedPromise: Promise = new Promise((resolve, reject) => { - let hostkey_old: string = '' - let isKeyVerified: boolean = false + let hostkey_old = '' + let isKeyVerified = false ssh.on('handshake', async handshake => { if (isKeyVerified) { resolve() From 53560854a2b855b12215211b94b9a6ada813b6ca Mon Sep 17 00:00:00 2001 From: cfs4819 Date: Tue, 26 Mar 2024 10:56:06 +0800 Subject: [PATCH 4/4] Fix SSH X11 Repeated Handshake Issue --- tabby-ssh/src/session/ssh.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tabby-ssh/src/session/ssh.ts b/tabby-ssh/src/session/ssh.ts index 742dece765..e9d54abdb0 100644 --- a/tabby-ssh/src/session/ssh.ts +++ b/tabby-ssh/src/session/ssh.ts @@ -205,15 +205,15 @@ export class SSHSession { } const hostVerifiedPromise: Promise = new Promise((resolve, reject) => { - let hostkey_old = '' + let hostkeyOld = '' let isKeyVerified = false ssh.on('handshake', async handshake => { if (isKeyVerified) { resolve() return } - if (hostkey_old !== handshake.serverHostKey) { - hostkey_old = handshake.serverHostKey + if (hostkeyOld !== handshake.serverHostKey) { + hostkeyOld = handshake.serverHostKey if (!await this.verifyHostKey(handshake)) { this.ssh.end() reject(new Error('Host key verification failed'))