[client] Deduplicate SSH PTY session setup and host key verification

Extract the identical PTY session setup shared by the wasm and Android
terminal clients into ssh.StartPTYSession, and move the stored-key host
verification onto the engine so the embed client delegates and the
Android client passes the engine directly as HostKeyVerifier.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Zoltan Papp
2026-08-14 17:49:31 +02:00
parent 16f7e1e148
commit 2da4512272
5 changed files with 100 additions and 103 deletions

View File

@@ -12,6 +12,7 @@ import (
firewallManager "github.com/netbirdio/netbird/client/firewall/manager"
"github.com/netbirdio/netbird/client/iface/netstack"
nftypes "github.com/netbirdio/netbird/client/internal/netflow/types"
nbssh "github.com/netbirdio/netbird/client/ssh"
sshauth "github.com/netbirdio/netbird/client/ssh/auth"
sshconfig "github.com/netbirdio/netbird/client/ssh/config"
sshserver "github.com/netbirdio/netbird/client/ssh/server"
@@ -216,6 +217,16 @@ func (e *Engine) GetPeerSSHKey(peerAddress string) ([]byte, bool) {
return nil, false
}
// VerifySSHHostKey verifies a presented SSH host key against the stored key of
// the peer at peerAddress. It implements ssh.HostKeyVerifier.
func (e *Engine) VerifySSHHostKey(peerAddress string, presentedKey []byte) error {
storedKey, found := e.GetPeerSSHKey(peerAddress)
if !found {
return nbssh.ErrPeerNotFound
}
return nbssh.VerifyHostKey(storedKey, presentedKey, peerAddress)
}
// cleanupSSHConfig removes NetBird SSH client configuration on shutdown
func (e *Engine) cleanupSSHConfig() {
if netstack.IsEnabled() {