mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 21:36:17 +00:00
made it a while loop to not do the rest of the auth methods if one suceeds
This commit is contained in:
@@ -71,29 +71,29 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
|
|||||||
|
|
||||||
//TODO: check hostkey
|
//TODO: check hostkey
|
||||||
|
|
||||||
for method in getAuthMethods() {
|
while state != .authorized {
|
||||||
switch method {
|
for method in getAuthMethods() {
|
||||||
case .password:
|
switch method {
|
||||||
do { try authWithPw() } catch {
|
case .password:
|
||||||
state = .authFailed
|
do { try authWithPw() } catch {
|
||||||
print("pw auth error")
|
state = .authFailed
|
||||||
print(error.localizedDescription)
|
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, "TERM", "xterm-256color")
|
||||||
ssh_channel_request_env(channel, "LANG", "en_US.UTF-8")
|
ssh_channel_request_env(channel, "LANG", "en_US.UTF-8")
|
||||||
ssh_channel_request_env(channel, "LC_ALL", "en_US.UTF-8")
|
ssh_channel_request_env(channel, "LC_ALL", "en_US.UTF-8")
|
||||||
|
|||||||
Reference in New Issue
Block a user