From 4f7b948fa49ea4b8098787435f54020386c53aac Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Thu, 3 Jul 2025 12:35:51 +0100 Subject: [PATCH] made it a while loop to not do the rest of the auth methods if one suceeds --- ShhShell/SSH/SSHHandler.swift | 38 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/ShhShell/SSH/SSHHandler.swift b/ShhShell/SSH/SSHHandler.swift index 31e71bd..3ab65f5 100644 --- a/ShhShell/SSH/SSHHandler.swift +++ b/ShhShell/SSH/SSHHandler.swift @@ -71,29 +71,29 @@ class SSHHandler: @unchecked Sendable, ObservableObject { //TODO: check hostkey - for method in getAuthMethods() { - switch method { - case .password: - do { try authWithPw() } catch { - state = .authFailed - print("pw auth error") - print(error.localizedDescription) + while state != .authorized { + for method in getAuthMethods() { + switch method { + case .password: + do { try authWithPw() } catch { + state = .authFailed + print("pw auth error") + print(error.localizedDescription) + } + case .publickey: + do { try authWithPubkey() } catch { + state = .authFailed + print("error with pubkey auth") + print(error.localizedDescription) + } + case .hostbased: + disconnect() + case .interactive: + disconnect() } - case .publickey: - do { try authWithPubkey() } catch { - state = .authFailed - print("error with pubkey auth") - print(error.localizedDescription) - } - case .hostbased: - disconnect() - case .interactive: - disconnect() } } - guard state == .authorized else { return } - ssh_channel_request_env(channel, "TERM", "xterm-256color") ssh_channel_request_env(channel, "LANG", "en_US.UTF-8") ssh_channel_request_env(channel, "LC_ALL", "en_US.UTF-8")