Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed6e96b3c1 | ||
|
|
37a70edbab | ||
|
|
ebb838b6b1 | ||
|
|
4fd711474c |
@@ -0,0 +1,38 @@
|
|||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// Eingabe-Prüfung + Bereinigung für Profile (reine Funktionen, testbar).
|
||||||
|
/// Fängt die häufigsten „Verbindung falsch"-Ursachen ab: Leerzeichen,
|
||||||
|
/// user@host im Host-Feld, Protokoll-Präfix, leerer Benutzername.
|
||||||
|
enum ProfileValidation {
|
||||||
|
static func cleaned(_ profile: ConnectionProfile) -> ConnectionProfile {
|
||||||
|
var p = profile
|
||||||
|
p.name = p.name.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
p.host = p.host.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
p.username = p.username.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
p.group = p.group.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
p.resolution = p.resolution.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
p.extraArgs = p.extraArgs.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
static func warnings(for profile: ConnectionProfile) -> [String] {
|
||||||
|
var w: [String] = []
|
||||||
|
let h = profile.host.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
if h.contains("@") {
|
||||||
|
w.append("Host enthält „@“ — den Benutzernamen ins Feld darunter eintragen, hier nur Hostname/IP.")
|
||||||
|
}
|
||||||
|
if h.contains("://") {
|
||||||
|
w.append("Host enthält „://“ — nur Hostname/IP, kein Protokoll (das steht oben).")
|
||||||
|
}
|
||||||
|
if h.contains(where: { $0.isWhitespace }) {
|
||||||
|
w.append("Host enthält Leerzeichen.")
|
||||||
|
}
|
||||||
|
if profile.username.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||||
|
w.append("Benutzername fehlt.")
|
||||||
|
}
|
||||||
|
if !(1...65535).contains(profile.port) {
|
||||||
|
w.append("Port ungültig (1–65535).")
|
||||||
|
}
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,6 +39,67 @@ enum SSHService {
|
|||||||
NSPasteboard.general.clearContents()
|
NSPasteboard.general.clearContents()
|
||||||
NSPasteboard.general.setString(cmd, forType: .string)
|
NSPasteboard.general.setString(cmd, forType: .string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Passwort / Auto-Login
|
||||||
|
|
||||||
|
/// SSH-Agent-Socket für GUI-Prozesse auflösen (Finder-Apps erben SSH_AUTH_SOCK
|
||||||
|
/// nicht, Terminal schon — ohne diesen Unterschied nutzt Terminal evtl. einen
|
||||||
|
/// Agent-Key, während die App nach dem Passwort fragt und scheitert).
|
||||||
|
static func agentSocket() -> String? {
|
||||||
|
let p = Process()
|
||||||
|
p.executableURL = URL(fileURLWithPath: "/bin/launchctl")
|
||||||
|
p.arguments = ["getenv", "SSH_AUTH_SOCK"]
|
||||||
|
let out = Pipe()
|
||||||
|
let err = Pipe()
|
||||||
|
p.standardOutput = out
|
||||||
|
p.standardError = err
|
||||||
|
do {
|
||||||
|
try p.run()
|
||||||
|
p.waitUntilExit()
|
||||||
|
} catch {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
let path = String(data: out.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?
|
||||||
|
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||||
|
guard !path.isEmpty,
|
||||||
|
FileManager.default.fileExists(atPath: path) else { return nil }
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gespeichertes Login-Secret: erst Profil-Passwort, dann Key-Passphrase (Keychain, nie JSON).
|
||||||
|
static func loginSecret(for profile: ConnectionProfile, key: StoredSSHKey?) -> String? {
|
||||||
|
if let acct = profile.passwordAccount,
|
||||||
|
let pw = KeychainHelper.load(account: acct), !pw.isEmpty {
|
||||||
|
return pw
|
||||||
|
}
|
||||||
|
if let key, let acct = key.passphraseAccount,
|
||||||
|
let pp = KeychainHelper.load(account: acct), !pp.isEmpty {
|
||||||
|
return pp
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
static func findSshpass() -> String? {
|
||||||
|
for p in ["/opt/homebrew/bin/sshpass", "/usr/local/bin/sshpass", "/usr/bin/sshpass"] {
|
||||||
|
if FileManager.default.isExecutableFile(atPath: p) { return p }
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/// true = beim Verbinden wird ohne Tippen eingeloggt (sshpass + Keychain-Secret).
|
||||||
|
static func willAutoLogin(profile: ConnectionProfile, key: StoredSSHKey?) -> Bool {
|
||||||
|
loginSecret(for: profile, key: key) != nil && findSshpass() != nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reine Funktion (testbar): mit Secret+sshpass -> sshpass -e … + SSHPASS-Env,
|
||||||
|
/// sonst direkter Aufruf. Passwort steht NIE in der Befehlszeile (nur im Env).
|
||||||
|
static func sessionConfig(executable: String, args: [String], password: String?, sshpassPath: String?)
|
||||||
|
-> (executable: String, arguments: [String], extraEnv: [String: String], autoLogin: Bool) {
|
||||||
|
if let password, !password.isEmpty, let sshpass = sshpassPath, !sshpass.isEmpty {
|
||||||
|
return (sshpass, ["-e", executable] + args, ["SSHPASS": password], true)
|
||||||
|
}
|
||||||
|
return (executable, args, [:], false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum RDPService {
|
enum RDPService {
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ enum PTYState: Equatable {
|
|||||||
final class PTYSession: ObservableObject {
|
final class PTYSession: ObservableObject {
|
||||||
@Published private(set) var lines: [[StyledText]] = [[]]
|
@Published private(set) var lines: [[StyledText]] = [[]]
|
||||||
@Published private(set) var state: PTYState = .never
|
@Published private(set) var state: PTYState = .never
|
||||||
|
@Published private(set) var autoLogin = false
|
||||||
|
|
||||||
var executable = ""
|
var executable = ""
|
||||||
var arguments: [String] = []
|
var arguments: [String] = []
|
||||||
|
var customEnv: [String: String] = [:]
|
||||||
|
|
||||||
private var masterFD: Int32 = -1
|
private var masterFD: Int32 = -1
|
||||||
private var process: Process?
|
private var process: Process?
|
||||||
@@ -48,6 +50,10 @@ final class PTYSession: ObservableObject {
|
|||||||
self.arguments = arguments
|
self.arguments = arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setAutoLogin(_ value: Bool) {
|
||||||
|
autoLogin = value
|
||||||
|
}
|
||||||
|
|
||||||
func start() {
|
func start() {
|
||||||
cleanupSync()
|
cleanupSync()
|
||||||
epoch += 1
|
epoch += 1
|
||||||
@@ -79,6 +85,7 @@ final class PTYSession: ObservableObject {
|
|||||||
var env = ProcessInfo.processInfo.environment
|
var env = ProcessInfo.processInfo.environment
|
||||||
env["TERM"] = "xterm-256color"
|
env["TERM"] = "xterm-256color"
|
||||||
if env["LANG"] == nil { env["LANG"] = "de_DE.UTF-8" }
|
if env["LANG"] == nil { env["LANG"] = "de_DE.UTF-8" }
|
||||||
|
for (k, v) in customEnv { env[k] = v }
|
||||||
p.environment = env
|
p.environment = env
|
||||||
// closeOnDealloc=false: Parent schließt slave explizit nach run().
|
// closeOnDealloc=false: Parent schließt slave explizit nach run().
|
||||||
p.standardInput = FileHandle(fileDescriptor: slave)
|
p.standardInput = FileHandle(fileDescriptor: slave)
|
||||||
@@ -282,11 +289,27 @@ final class TerminalManager: ObservableObject {
|
|||||||
func session(for profile: ConnectionProfile, key: StoredSSHKey?) -> PTYSession {
|
func session(for profile: ConnectionProfile, key: StoredSSHKey?) -> PTYSession {
|
||||||
if let existing = sessions[profile.id] { return existing }
|
if let existing = sessions[profile.id] { return existing }
|
||||||
let s = PTYSession()
|
let s = PTYSession()
|
||||||
|
let baseExe: String
|
||||||
|
let baseArgs: [String]
|
||||||
if profile.proto == .sftp {
|
if profile.proto == .sftp {
|
||||||
s.configure(executable: "/usr/bin/sftp", arguments: ["-P", "\(profile.port)"] + (key.map { ["-i", $0.privateKeyPath] } ?? []) + ["\(profile.username)@\(profile.host)"])
|
baseExe = "/usr/bin/sftp"
|
||||||
|
baseArgs = ["-P", "\(profile.port)"] + (key.map { ["-i", $0.privateKeyPath] } ?? []) + ["\(profile.username)@\(profile.host)"]
|
||||||
} else {
|
} else {
|
||||||
s.configure(executable: "/usr/bin/ssh", arguments: SSHService.sshArguments(for: profile, key: key))
|
baseExe = "/usr/bin/ssh"
|
||||||
|
baseArgs = SSHService.sshArguments(for: profile, key: key)
|
||||||
}
|
}
|
||||||
|
// Auto-Login nur mit Keychain-Secret + sshpass, sonst interaktiver Prompt im Terminal.
|
||||||
|
// SSH-Agent durchreichen (falls vorhanden): gleiche Keys wie in Terminal.app.
|
||||||
|
let cfg = SSHService.sessionConfig(executable: baseExe, args: baseArgs,
|
||||||
|
password: SSHService.loginSecret(for: profile, key: key),
|
||||||
|
sshpassPath: SSHService.findSshpass())
|
||||||
|
s.configure(executable: cfg.executable, arguments: cfg.arguments)
|
||||||
|
var env = cfg.extraEnv
|
||||||
|
if let sock = SSHService.agentSocket() {
|
||||||
|
env["SSH_AUTH_SOCK"] = sock
|
||||||
|
}
|
||||||
|
s.customEnv = env
|
||||||
|
s.setAutoLogin(cfg.autoLogin)
|
||||||
sessions[profile.id] = s
|
sessions[profile.id] = s
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.sheet(item: $editingProfile) { profile in
|
.sheet(item: $editingProfile) { profile in
|
||||||
ProfileEditorView(profile: profile) { saved in
|
ProfileEditorView(profile: profile, isNew: !store.profiles.contains(where: { $0.id == profile.id })) { saved in
|
||||||
if store.profiles.contains(where: { $0.id == saved.id }) {
|
if store.profiles.contains(where: { $0.id == saved.id }) {
|
||||||
store.update(saved)
|
store.update(saved)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -41,8 +41,15 @@ struct EmbeddedTerminalView: View {
|
|||||||
Text(lastMessage)
|
Text(lastMessage)
|
||||||
.font(.caption).foregroundStyle(Dracula.foreground)
|
.font(.caption).foregroundStyle(Dracula.foreground)
|
||||||
.lineLimit(3)
|
.lineLimit(3)
|
||||||
|
if lastMessage.localizedCaseInsensitiveContains("permission denied") {
|
||||||
|
Text("Tipp: Passwort im Auge-Modus eingeben, Tastaturlayout prüfen. Falls Terminal.app ohne Passwort einloggt (Agent-Key: ssh-add -l), Key in der App hinterlegen oder Agent nutzen.")
|
||||||
|
.font(.caption).foregroundStyle(Dracula.orange)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
|
Button("Bericht kopieren") { copyReport() }
|
||||||
|
.buttonStyle(.link).font(.caption)
|
||||||
|
.help("Kopiert Profil (ohne Passwort), Status und letzte Ausgabe — hierher schicken zur Fehlersuche")
|
||||||
Button("Diagnose") { diagnose() }.buttonStyle(.link).font(.caption)
|
Button("Diagnose") { diagnose() }.buttonStyle(.link).font(.caption)
|
||||||
Button("Erneut") { connect() }.buttonStyle(.link).font(.caption)
|
Button("Erneut") { connect() }.buttonStyle(.link).font(.caption)
|
||||||
}
|
}
|
||||||
@@ -58,16 +65,17 @@ struct EmbeddedTerminalView: View {
|
|||||||
// Eingabezeile
|
// Eingabezeile
|
||||||
HStack(spacing: 6) {
|
HStack(spacing: 6) {
|
||||||
Text("❯").font(.system(.body, design: .monospaced)).foregroundStyle(Dracula.green)
|
Text("❯").font(.system(.body, design: .monospaced)).foregroundStyle(Dracula.green)
|
||||||
if secureInput {
|
// Gehärtetes Feld: keine macOS-Text-Ersetzungen (Passwort-Sonderzeichen!)
|
||||||
SecureField("Eingabe (versteckt, z. B. Passwort) …", text: $input, onCommit: submit)
|
ZStack(alignment: .leading) {
|
||||||
.textFieldStyle(.plain)
|
if input.isEmpty {
|
||||||
.font(.system(.body, design: .monospaced))
|
Text(secureInput ? "Eingabe (versteckt, z. B. Passwort) …" : "Eingabe …")
|
||||||
.foregroundStyle(Dracula.foreground)
|
.font(.system(.body, design: .monospaced))
|
||||||
} else {
|
.foregroundStyle(Dracula.comment.opacity(0.7))
|
||||||
TextField("Eingabe …", text: $input, onCommit: submit)
|
.allowsHitTesting(false)
|
||||||
.textFieldStyle(.plain)
|
}
|
||||||
.font(.system(.body, design: .monospaced))
|
TerminalInputField(text: $input, isSecure: secureInput, onSubmit: submit)
|
||||||
.foregroundStyle(Dracula.foreground)
|
.id(secureInput)
|
||||||
|
.frame(height: 22)
|
||||||
}
|
}
|
||||||
Button(action: { secureInput.toggle() }) {
|
Button(action: { secureInput.toggle() }) {
|
||||||
Image(systemName: secureInput ? "eye.slash" : "eye")
|
Image(systemName: secureInput ? "eye.slash" : "eye")
|
||||||
@@ -129,6 +137,20 @@ struct EmbeddedTerminalView: View {
|
|||||||
input = ""
|
input = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fehlerbericht ohne Secrets (Passwort steht weder im Profil noch im Befehl).
|
||||||
|
/// Hinweis: Wer das Passwort sichtbar eingetippt hat (nicht Auge-Modus),
|
||||||
|
/// löscht die Ausgabe vorher per „Leeren".
|
||||||
|
func copyReport() {
|
||||||
|
var r = "RemminaMac Fehlerbericht\n"
|
||||||
|
r += "Profil: \(profile.name) | \(profile.proto.rawValue) | \(profile.username)@\(profile.host):\(profile.port)\n"
|
||||||
|
r += "Auto-Login: \(term.autoLogin ? "ja" : "nein") | sshpass: \(SSHService.findSshpass() ?? "fehlt")\n"
|
||||||
|
r += "Status: \(statusText)\n"
|
||||||
|
let tail = term.lines.suffix(20).map { $0.map(\.text).joined() }.joined(separator: "\n")
|
||||||
|
r += "--- letzte Ausgabe ---\n\(tail)\n"
|
||||||
|
NSPasteboard.general.clearContents()
|
||||||
|
NSPasteboard.general.setString(r, forType: .string)
|
||||||
|
}
|
||||||
|
|
||||||
var failed: Bool {
|
var failed: Bool {
|
||||||
if case .done(let code, _) = term.state {
|
if case .done(let code, _) = term.state {
|
||||||
return (code ?? 1) != 0
|
return (code ?? 1) != 0
|
||||||
@@ -164,7 +186,7 @@ struct EmbeddedTerminalView: View {
|
|||||||
if checking { return "Prüfe \(profile.host):\(profile.port) …" }
|
if checking { return "Prüfe \(profile.host):\(profile.port) …" }
|
||||||
switch term.state {
|
switch term.state {
|
||||||
case .never: return canConnect ? "Bereit — verbindet beim Öffnen." : "Host/Benutzer fehlt."
|
case .never: return canConnect ? "Bereit — verbindet beim Öffnen." : "Host/Benutzer fehlt."
|
||||||
case .running: return "Verbunden (PTY, TERM=xterm-256color)."
|
case .running: return term.autoLogin ? "Verbunden (Auto-Login via Keychain)." : "Verbunden (PTY, TERM=xterm-256color)."
|
||||||
case .done(_, let msg): return msg
|
case .done(_, let msg): return msg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,18 +4,23 @@ struct ProfileEditorView: View {
|
|||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
@EnvironmentObject var store: ProfileStore
|
@EnvironmentObject var store: ProfileStore
|
||||||
@State var profile: ConnectionProfile
|
@State var profile: ConnectionProfile
|
||||||
|
var isNew: Bool
|
||||||
var onSave: (ConnectionProfile) -> Void
|
var onSave: (ConnectionProfile) -> Void
|
||||||
@State private var password: String = ""
|
@State private var password: String = ""
|
||||||
@State private var savePassword: Bool = false
|
@State private var savePassword: Bool = false
|
||||||
|
@State private var storedPasswordPresent: Bool = false
|
||||||
|
|
||||||
init(profile: ConnectionProfile, onSave: @escaping (ConnectionProfile) -> Void) {
|
init(profile: ConnectionProfile, isNew: Bool, onSave: @escaping (ConnectionProfile) -> Void) {
|
||||||
_profile = State(initialValue: profile)
|
_profile = State(initialValue: profile)
|
||||||
|
self.isNew = isNew
|
||||||
self.onSave = onSave
|
self.onSave = onSave
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var liveWarnings: [String] { ProfileValidation.warnings(for: profile) }
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
Text(profile.id.uuidString.prefix(8) == ConnectionProfile().id.uuidString.prefix(8) ? "Profil bearbeiten" : "Profil").font(.headline).padding()
|
Text(isNew ? "Neues Profil" : "Profil bearbeiten").font(.headline).padding()
|
||||||
Form {
|
Form {
|
||||||
Section("Allgemein") {
|
Section("Allgemein") {
|
||||||
TextField("Name", text: $profile.name)
|
TextField("Name", text: $profile.name)
|
||||||
@@ -34,18 +39,38 @@ struct ProfileEditorView: View {
|
|||||||
}
|
}
|
||||||
Section("Verbindung") {
|
Section("Verbindung") {
|
||||||
TextField("Host", text: $profile.host)
|
TextField("Host", text: $profile.host)
|
||||||
|
.autocorrectionDisabled()
|
||||||
TextField("Port", value: $profile.port, format: .number)
|
TextField("Port", value: $profile.port, format: .number)
|
||||||
TextField("Benutzername", text: $profile.username)
|
TextField("Benutzername", text: $profile.username)
|
||||||
|
.autocorrectionDisabled()
|
||||||
|
// Passwort direkt unter dem Benutzernamen (Keychain-gespeichert)
|
||||||
|
if storedPasswordPresent && password.isEmpty {
|
||||||
|
HStack {
|
||||||
|
Image(systemName: "checkmark.circle.fill").foregroundStyle(.green)
|
||||||
|
Text("Passwort gespeichert")
|
||||||
|
Spacer()
|
||||||
|
Button("Löschen", role: .destructive) { deleteStoredPassword() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SecureField(storedPasswordPresent ? "Neues Passwort …" : "Passwort", text: $password)
|
||||||
|
Toggle("Passwort in Keychain speichern", isOn: $savePassword)
|
||||||
TextField("Auflösung (RDP, z. B. 1920x1080 oder Automatisch)", text: $profile.resolution)
|
TextField("Auflösung (RDP, z. B. 1920x1080 oder Automatisch)", text: $profile.resolution)
|
||||||
TextField("Extra-Argumente", text: $profile.extraArgs)
|
TextField("Extra-Argumente", text: $profile.extraArgs)
|
||||||
|
if !liveWarnings.isEmpty {
|
||||||
|
ForEach(liveWarnings, id: \.self) { w in
|
||||||
|
HStack(spacing: 6) {
|
||||||
|
Image(systemName: "exclamationmark.triangle").foregroundStyle(.orange)
|
||||||
|
Text(w).font(.caption).foregroundStyle(.orange)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Section("Authentifizierung") {
|
Section("SSH-Key (optional)") {
|
||||||
Picker("SSH-Key", selection: $profile.sshKeyID) {
|
Picker("SSH-Key", selection: $profile.sshKeyID) {
|
||||||
Text("Kein Key").tag(UUID?.none)
|
Text("Kein Key (Passwort-Login)").tag(UUID?.none)
|
||||||
ForEach(store.sshKeys) { k in Text(k.name).tag(UUID?.some(k.id)) }
|
ForEach(store.sshKeys) { k in Text(k.name).tag(UUID?.some(k.id)) }
|
||||||
}
|
}
|
||||||
SecureField("Passwort (optional, Keychain)", text: $password)
|
Text(sshpassHint).font(.caption).foregroundStyle(.secondary)
|
||||||
Toggle("Passwort in Keychain speichern", isOn: $savePassword)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.formStyle(.grouped)
|
.formStyle(.grouped)
|
||||||
@@ -54,7 +79,7 @@ struct ProfileEditorView: View {
|
|||||||
Button("Abbrechen", role: .cancel) { dismiss() }
|
Button("Abbrechen", role: .cancel) { dismiss() }
|
||||||
Spacer()
|
Spacer()
|
||||||
Button("Speichern") {
|
Button("Speichern") {
|
||||||
var toSave = profile
|
var toSave = ProfileValidation.cleaned(profile)
|
||||||
if toSave.port == 0 { toSave.port = toSave.proto.defaultPort }
|
if toSave.port == 0 { toSave.port = toSave.proto.defaultPort }
|
||||||
if toSave.passwordAccount == nil { toSave.passwordAccount = "profile-\(toSave.id.uuidString)" }
|
if toSave.passwordAccount == nil { toSave.passwordAccount = "profile-\(toSave.id.uuidString)" }
|
||||||
if savePassword, !password.isEmpty, let acct = toSave.passwordAccount {
|
if savePassword, !password.isEmpty, let acct = toSave.passwordAccount {
|
||||||
@@ -64,16 +89,35 @@ struct ProfileEditorView: View {
|
|||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
.keyboardShortcut(.defaultAction)
|
.keyboardShortcut(.defaultAction)
|
||||||
.disabled(profile.host.isEmpty || profile.name.isEmpty)
|
.disabled(profile.name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
||||||
|
|| profile.host.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
.frame(width: 520, height: 620)
|
.frame(width: 520, height: 680)
|
||||||
.onAppear {
|
.onAppear {
|
||||||
if let acct = profile.passwordAccount {
|
if let acct = profile.passwordAccount,
|
||||||
password = KeychainHelper.load(account: acct) ?? ""
|
let stored = KeychainHelper.load(account: acct), !stored.isEmpty {
|
||||||
savePassword = !password.isEmpty
|
storedPasswordPresent = true
|
||||||
|
savePassword = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sshpassHint: String {
|
||||||
|
if SSHService.findSshpass() != nil {
|
||||||
|
return "sshpass gefunden → Auto-Login mit Keychain-Passwort aktiv, kein Tippen nötig."
|
||||||
|
} else {
|
||||||
|
return "Ohne sshpass: Passwort wird beim Verbinden im Terminal abgefragt. Für Auto-Login: brew install sshpass."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func deleteStoredPassword() {
|
||||||
|
if let acct = profile.passwordAccount {
|
||||||
|
KeychainHelper.delete(account: acct)
|
||||||
|
}
|
||||||
|
password = ""
|
||||||
|
savePassword = false
|
||||||
|
storedPasswordPresent = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
import SwiftUI
|
||||||
|
import AppKit
|
||||||
|
|
||||||
|
/// Eingabefeld ohne macOS-Text-Ersetzungen (Anführungszeichen, Gedankenstriche,
|
||||||
|
/// Auto-Korrektur, Punkt-Verdopplung, Vervollständigung, Links/Daten-Erkennung).
|
||||||
|
/// Hintergrund: Normale Textfelder ersetzen still z. B. `"` durch „“ und `--`
|
||||||
|
/// durch — (je nach Tastatur-Einstellung). Im Terminal fällt das nicht auf, aber
|
||||||
|
/// ein Passwort mit Sonderzeichen kommt falsch bei ssh an → „Permission denied",
|
||||||
|
/// obwohl das Passwort „stimmt" (docs/ERRORS.md #13).
|
||||||
|
/// NSTextField kann das nicht alles abschalten, daher NSTextView-Basis.
|
||||||
|
/// Secure-Modus nutzt NSSecureTextField (per Design ohne Ersetzungen).
|
||||||
|
struct TerminalInputField: NSViewRepresentable {
|
||||||
|
@Binding var text: String
|
||||||
|
var isSecure: Bool
|
||||||
|
var onSubmit: () -> Void
|
||||||
|
|
||||||
|
func makeCoordinator() -> Coordinator {
|
||||||
|
Coordinator(text: $text, onSubmit: onSubmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeNSView(context: Context) -> NSView {
|
||||||
|
if isSecure {
|
||||||
|
let f = NSSecureTextField()
|
||||||
|
f.font = .monospacedSystemFont(ofSize: 13, weight: .regular)
|
||||||
|
f.textColor = Dracula.nsColor(for: nil)
|
||||||
|
f.backgroundColor = .clear
|
||||||
|
f.isBordered = false
|
||||||
|
f.focusRingType = .none
|
||||||
|
f.delegate = context.coordinator
|
||||||
|
return f
|
||||||
|
} else {
|
||||||
|
let tv = NSTextView()
|
||||||
|
Self.configure(tv)
|
||||||
|
tv.delegate = context.coordinator
|
||||||
|
return tv
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateNSView(_ view: NSView, context: Context) {
|
||||||
|
context.coordinator.onSubmit = onSubmit
|
||||||
|
if let f = view as? NSTextField, f.stringValue != text {
|
||||||
|
f.stringValue = text
|
||||||
|
} else if let tv = view as? NSTextView, tv.string != text {
|
||||||
|
tv.string = text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Alle Ersetzungen aus. Auch als Harness-Test nutzbar (reine Flags, headless).
|
||||||
|
static func configure(_ tv: NSTextView) {
|
||||||
|
tv.isRichText = false
|
||||||
|
tv.importsGraphics = false
|
||||||
|
tv.isAutomaticQuoteSubstitutionEnabled = false
|
||||||
|
tv.isAutomaticDashSubstitutionEnabled = false
|
||||||
|
tv.isAutomaticTextCompletionEnabled = false
|
||||||
|
tv.isAutomaticSpellingCorrectionEnabled = false
|
||||||
|
tv.isContinuousSpellCheckingEnabled = false
|
||||||
|
tv.isAutomaticDataDetectionEnabled = false
|
||||||
|
tv.isAutomaticLinkDetectionEnabled = false
|
||||||
|
tv.isAutomaticTextReplacementEnabled = false
|
||||||
|
tv.font = .monospacedSystemFont(ofSize: 13, weight: .regular)
|
||||||
|
tv.textColor = Dracula.nsColor(for: nil)
|
||||||
|
tv.backgroundColor = .clear
|
||||||
|
tv.drawsBackground = false
|
||||||
|
tv.isVerticallyResizable = false
|
||||||
|
tv.isHorizontallyResizable = true
|
||||||
|
tv.textContainer?.widthTracksTextView = false
|
||||||
|
tv.textContainer?.containerSize = NSSize(width: 100000, height: 24)
|
||||||
|
}
|
||||||
|
|
||||||
|
final class Coordinator: NSObject, NSTextFieldDelegate, NSTextViewDelegate {
|
||||||
|
var text: Binding<String>
|
||||||
|
var onSubmit: () -> Void
|
||||||
|
|
||||||
|
init(text: Binding<String>, onSubmit: @escaping () -> Void) {
|
||||||
|
self.text = text
|
||||||
|
self.onSubmit = onSubmit
|
||||||
|
}
|
||||||
|
|
||||||
|
func controlTextDidChange(_ obj: Notification) {
|
||||||
|
if let f = obj.object as? NSTextField {
|
||||||
|
text.wrappedValue = f.stringValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
||||||
|
if commandSelector == #selector(NSResponder.insertNewline(_:)) {
|
||||||
|
onSubmit()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func textDidChange(_ notification: Notification) {
|
||||||
|
if let tv = notification.object as? NSTextView {
|
||||||
|
// Einzeiler: harte Umbrüche sofort entfernen (Paste mit \n)
|
||||||
|
let single = tv.string.replacingOccurrences(of: "\n", with: "")
|
||||||
|
if single != tv.string { tv.string = single }
|
||||||
|
text.wrappedValue = single
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func textView(_ textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
||||||
|
if commandSelector == #selector(NSResponder.insertNewline(_:)) {
|
||||||
|
onSubmit()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,10 @@ Stand: 2026-09-21 · Version 0.1.0 · macOS arm64 · Swift 5.9+ · Xcode 15+
|
|||||||
| 8 | 2026-09-21 | SSH-Session stirbt instant ohne Meldung | stderr hing mit am PTY: macOS verwirft ungelesene Master-Daten bei Slave-Close → „Code 255" ohne Text | blockierend | ✅ behoben — stderr→Pipe, TCP-Vorab-Check, Fehler-Banner |
|
| 8 | 2026-09-21 | SSH-Session stirbt instant ohne Meldung | stderr hing mit am PTY: macOS verwirft ungelesene Master-Daten bei Slave-Close → „Code 255" ohne Text | blockierend | ✅ behoben — stderr→Pipe, TCP-Vorab-Check, Fehler-Banner |
|
||||||
| 9 | 2026-09-21 | `swift build` | `Result<Void, String>`: String conformt nicht zu Error (Folgefehler: DispatchQueue-Overload) | blockierend | ✅ behoben — Completion als `(String?) -> Void` |
|
| 9 | 2026-09-21 | `swift build` | `Result<Void, String>`: String conformt nicht zu Error (Folgefehler: DispatchQueue-Overload) | blockierend | ✅ behoben — Completion als `(String?) -> Void` |
|
||||||
| 10 | 2026-09-21 | Icon-Generator (`RenderIcon.swift`) | 3 Swift-Fehler: `guard let x = f() ?? g()` (nicht optional), `Int * CGFloat`, falscher Preview-Pfad | klein | ✅ behoben |
|
| 10 | 2026-09-21 | Icon-Generator (`RenderIcon.swift`) | 3 Swift-Fehler: `guard let x = f() ?? g()` (nicht optional), `Int * CGFloat`, falscher Preview-Pfad | klein | ✅ behoben |
|
||||||
|
| 11 | 2026-09-21 | Passwort-Feature | Wunsch: Passwort + Keys speichern UND nutzen (bisher nur gespeichert, nie benutzt) | Feature | ✅ umgesetzt — Auto-Login via sshpass, sonst interaktiv |
|
||||||
|
| 12 | 2026-09-21 | „Immer Verbindung falsch" | User-Report ohne Details (Ziel/Credentials unbekannt) | offen | ⬜ Teils: Editor-Validierung + kopierbarer Fehlerbericht; warte auf Bericht |
|
||||||
|
| 13 | 2026-09-21 | Permission denied trotz richtigem Passwort | Text-Ersetzung im Eingabefeld verfälscht Sonderzeichen | hoch | ✅ behoben — gehärtetes Eingabefeld (alle Ersetzungen aus, 9/9 Tests) |
|
||||||
|
| 14 | 2026-09-21 | Terminal geht, App nicht (gleiches Passwort) | SSH-Agent-Socket fehlt GUI-Prozessen → evtl. Key-Login in Terminal | hoch | ✅ App reicht Agent jetzt durch; Gegenprobe beim User offen |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -116,6 +120,16 @@ TEXT: "\n\n— Sitzung beendet (Code 255). —\n" # <- Fehlermeldung fehlt!
|
|||||||
**Fix:** `TCPCheck.check` nutzt `(String?) -> Void` (nil = ok, sonst deutsche Meldung).
|
**Fix:** `TCPCheck.check` nutzt `(String?) -> Void` (nil = ok, sonst deutsche Meldung).
|
||||||
**Status:** ✅ behoben.
|
**Status:** ✅ behoben.
|
||||||
|
|
||||||
|
## #11 — Passwort speichern UND benutzen (User-Wunsch)
|
||||||
|
**Stand:** Passwort/Key-Passphrase wurden in der Keychain gespeichert, aber nie zum Einloggen benutzt (ssh fragte immer interaktiv).
|
||||||
|
**Umsetzung:**
|
||||||
|
- `SSHService.loginSecret()` (Profil-Passwort → Key-Passphrase), `sessionConfig()` (rein, testbar): mit Secret + sshpass → `sshpass -e ssh/sftp …` + `SSHPASS`-Env (nie Befehlszeile/Logs); sonst direkter Aufruf + interaktiver Prompt.
|
||||||
|
- `PTYSession.customEnv` + `autoLogin`-Flag, `TerminalManager` verdrahtet alles; Status zeigt „Auto-Login via Keychain".
|
||||||
|
- Editor: Gespeichert-Anzeige (✓), Löschen-Button, sshpass-Hinweis; Titel-Bug (`UUID`-Vergleich mit neuem Random-Objekt) via `isNew` ersetzt.
|
||||||
|
**Verifikation:** Config-Harness 9/9 (inkl. „Passwort nie in Befehlszeile"); echter Keychain-Roundtrip 7/7 (save/load/delete + Priorität + Fallback).
|
||||||
|
**Hinweis:** Ohne `sshpass` (`brew install sshpass`) bleibt es beim interaktiven Prompt — hier auf dem Build-Mac ebenfalls nicht installiert, getestet wurde der interaktive Pfad + Logik.
|
||||||
|
**Status:** ✅ umgesetzt.
|
||||||
|
|
||||||
## #10 — Icon-Generator Buildfehler
|
## #10 — Icon-Generator Buildfehler
|
||||||
**Log:** `guard let` auf nicht-optionalem Ausdruck (`??` unwrapt schon); `Int * CGFloat`; Preview lag in `.iconset/` statt `/tmp/`.
|
**Log:** `guard let` auf nicht-optionalem Ausdruck (`??` unwrapt schon); `Int * CGFloat`; Preview lag in `.iconset/` statt `/tmp/`.
|
||||||
**Fix:** `??`-Fallback direkt zuweisen; `CGFloat(...)`; Pfad korrigiert.
|
**Fix:** `??`-Fallback direkt zuweisen; `CGFloat(...)`; Pfad korrigiert.
|
||||||
@@ -153,3 +167,34 @@ Oder mit Token als Passwort: `git push https://<owner>:<token>@git.sysdaemon.xyz
|
|||||||
**Lokaler Stand:** Commit `cd834dc` + `dist/RemminaMac-0.1.0-macos-arm64.zip` sind fertig und warteten nur auf den Push.
|
**Lokaler Stand:** Commit `cd834dc` + `dist/RemminaMac-0.1.0-macos-arm64.zip` sind fertig und warteten nur auf den Push.
|
||||||
**Nachtrag 2026-09-21:** ✅ behoben — mit korrigierten Credentials: `GET /api/v1/user → 200 (login x3)`, Repo `x3/remmina-mac` erstellt (201), `git push -u origin main` ok, Release `v0.1.0` (id 1) + 2 Assets (ZIP + SHA256) hochgeladen.
|
**Nachtrag 2026-09-21:** ✅ behoben — mit korrigierten Credentials: `GET /api/v1/user → 200 (login x3)`, Repo `x3/remmina-mac` erstellt (201), `git push -u origin main` ok, Release `v0.1.0` (id 1) + 2 Assets (ZIP + SHA256) hochgeladen.
|
||||||
**Status:** ✅ behoben.
|
**Status:** ✅ behoben.
|
||||||
|
|
||||||
|
## #12 — „Immer Verbindung falsch" (User-Report, Details offen)
|
||||||
|
**Stand:** Gemeldet ohne Ziel-Host, Banner-Text oder Credentials — aus der Ferne nicht reproduzierbar. Systematische App-Fehler als Ursache weitgehend ausgeschlossen (PTY/ssh-Pfad, Fehlertext-Anzeige, TCP-Check und Keychain-Fluss sind per Harness verifiziert).
|
||||||
|
**Häufigste reale Ursachen (Checkliste):**
|
||||||
|
1. `user@host` im Host-Feld oder `ssh://`-Präfix → jetzt Live-Warnung im Editor
|
||||||
|
2. Leerzeichen/Vertipper in Host/User → wird jetzt getrimmt + gewarnt
|
||||||
|
3. Falsches Passwort / Key ohne Passphrase-Eintrag → Banner + Diagnose nutzen
|
||||||
|
4. Server blockt (Fail2ban, nur Key-Login erlaubt) → Server-Logs prüfen
|
||||||
|
**Umgesetzt:** `Models/ProfileValidation.swift` (trimmen + Warnungen, Harness 7/7), Passwort direkt unter Benutzername, „Bericht kopieren" im Fehler-Banner (ohne Secrets).
|
||||||
|
**Offen:** Bitte Banner-Text oder kopierten Bericht hierher schicken — dann steht die Ursache in einer Zeile.
|
||||||
|
**Status:** ⬜ wartet auf Fehlerbericht.
|
||||||
|
|
||||||
|
## #13 — Permission denied trotz richtigem Passwort (User-Fehlerbericht)
|
||||||
|
**Bericht:** `administrator@sysdaemon.xyz:22`, ssh fragt 3x Passwort → `Permission denied (publickey,password)`. Gleiches Passwort im Terminal.app funktioniert.
|
||||||
|
**Ursache:** Das Terminal-Eingabefeld war ein Standard-TextField. macOS ersetzt dort je nach Einstellung still Zeichen (`"` → „“, `--` → —, Auto-Korrektur). Ein Passwort mit Sonderzeichen kommt dadurch falsch bei ssh an — im Terminal fällt nichts auf, ssh sagt nur „denied". Verifiziert: Standard-`NSTextField` hat diese Schalter an bzw. `NSTextField` kann Dash-Ersetzung gar nicht abschalten (Compiler-Beweis).
|
||||||
|
**Fix (`Views/TerminalInputField.swift`):** Eigenes Eingabefeld auf `NSTextView`-Basis mit allen Ersetzungen explizit aus (Quotes, Dashes, Completion, Spelling, Data/Link-Erkennung, Text-Replacement, Plain-Text); Secure-Variante via `NSSecureTextField` (per Design ersetzungsfrei); Enter → Senden, Paste-Normalisierung (keine Umbrüche).
|
||||||
|
**Verifikation:** Harness 9/9 (alle Flags aus). Hinweis: Restrisiko Tastaturlayout (Z/Y) bleibt — Banner-Tipp ergänzt.
|
||||||
|
**Status:** ✅ behoben — bitte mit v0.5.1 erneut testen.
|
||||||
|
|
||||||
|
## #14 — Terminal.app loggt ein, RemminaMac nicht (gleiches Passwort)
|
||||||
|
**Stand (User-Antworten):** v0.5.1 installiert, Passwort-Login, Terminal.app funktioniert mit denselben Daten.
|
||||||
|
**Analyse:** App-seitig ist alles verifiziert (PTY, Fehleranzeige, Passwort-Loop mit Sonderzeichen, Eingabe-Ersetzungen aus). Gleiches Binary + gleiche Config → Unterschied muss aus der Umgebung kommen. Hauptkandidat: **SSH-Agent** — Finder-gestartete GUI-Prozesse erben `SSH_AUTH_SOCK` nicht. Nutzt Terminal unbemerkt einen Agent-Key (statt Passwort), scheitert die App mit Passwort. Verifiziert: `launchctl getenv SSH_AUTH_SOCK` liefert den Socket, Shell-Env wäre ohne Abfrage leer für GUI-Apps.
|
||||||
|
**Fix:** `SSHService.agentSocket()` (launchctl + Existenzprüfung) → `TerminalManager` injiziert `SSH_AUTH_SOCK` ins ssh-Env (koexistiert mit SSHPASS). Banner-Tipp ergänzt.
|
||||||
|
**Verifikation:** Harness 4/4 (Auflösung 0.07 s, Pfad existiert, `ssh -G` ok mit echtem + kaputtem Socket).
|
||||||
|
**Gegenprobe beim User (bitte ausführen):**
|
||||||
|
```bash
|
||||||
|
ssh-add -l
|
||||||
|
ssh -o IdentitiesOnly=yes administrator@sysdaemon.xyz
|
||||||
|
```
|
||||||
|
Zweite Zeile erzwingt Passwort-Login ohne Agent — scheitert sie auch im Terminal, war es immer der Agent-Key.
|
||||||
|
**Status:** ✅ App-Seite umgesetzt — warte auf Gegenprobe.
|
||||||
|
|||||||
+10
-3
@@ -7,10 +7,11 @@
|
|||||||
- **Toolbar:** `+` Neu, Stift Bearbeiten, Kopie-Symbol Duplizieren, Schlüssel Keys, `▶` Verbinden, `⚡` Quick-Connect.
|
- **Toolbar:** `+` Neu, Stift Bearbeiten, Kopie-Symbol Duplizieren, Schlüssel Keys, `▶` Verbinden, `⚡` Quick-Connect.
|
||||||
|
|
||||||
## Profil anlegen
|
## Profil anlegen
|
||||||
1. `+` → Name, Gruppe, Protokoll (SSH/SFTP/RDP/VNC), Host, Port, User ausfüllen.
|
1. `+` → Name, Gruppe, Protokoll (SSH/SFTP/RDP/VNC), Host, Port, Benutzername, **Passwort direkt darunter** ausfüllen (Keychain-Haken setzen zum Speichern).
|
||||||
2. SSH-Key wählen (vorher unter Schlüssel-Icon importieren).
|
2. Der Editor warnt live bei typischen Fehlern: `user@host` im Host-Feld, `ssh://`-Präfix, Leerzeichen, leerer Benutzername, ungültiger Port. Beim Speichern wird getrimmt.
|
||||||
3. Optional Passwort → Haken „in Keychain speichern“.
|
3. SSH-Key wählen (optional, Bereich darunter — vorher unter Schlüssel-Icon importieren).
|
||||||
4. Speichern → liegt sofort in `profiles.json`.
|
4. Speichern → liegt sofort in `profiles.json`.
|
||||||
|
5. Schlägt eine Verbindung fehl: rotes Banner → **Bericht kopieren** und zur Fehlersuche mitschicken (enthält kein Passwort).
|
||||||
|
|
||||||
## Verbinden
|
## Verbinden
|
||||||
- Profil wählen → `▶ Verbinden` oder Doppelklick.
|
- Profil wählen → `▶ Verbinden` oder Doppelklick.
|
||||||
@@ -25,6 +26,12 @@
|
|||||||
- `Neuen Key generieren`: ruft `/usr/bin/ssh-keygen -t ed25519 -f ~/.ssh/remminamac_<timestamp>` auf.
|
- `Neuen Key generieren`: ruft `/usr/bin/ssh-keygen -t ed25519 -f ~/.ssh/remminamac_<timestamp>` auf.
|
||||||
- Passphrase → Keychain (`sshkey-<UUID>`).
|
- Passphrase → Keychain (`sshkey-<UUID>`).
|
||||||
|
|
||||||
|
## Passwort speichern & Auto-Login
|
||||||
|
- Im Profil-Editor: Passwort eingeben + „in Keychain speichern“. Gespeichertes Passwort wird angezeigt (✓) und kann gelöscht werden. In `profiles.json` steht nur die Referenz, nie das Passwort.
|
||||||
|
- Reihenfolge beim Verbinden: Profil-Passwort zuerst, sonst Key-Passphrase.
|
||||||
|
- **Auto-Login ohne Tippen:** braucht `sshpass` (`brew install sshpass`). Dann loggt ssh via Keychain-Secret ein (Passwort nur im Prozess-Env `SSHPASS`, nie in Befehlszeile/Logs). Status zeigt „Auto-Login via Keychain".
|
||||||
|
- **Ohne sshpass:** Passwort/Key-Passphrase wird interaktiv im Terminal abgefragt (Passwort-Modus: Auge-Icon). Bei Sonderzeichen im Passwort immer Auge-Modus nutzen (keine Text-Ersetzung).
|
||||||
|
|
||||||
## Quick-Connect
|
## Quick-Connect
|
||||||
- Mit Auswahl: verbindet direkt. Ohne Auswahl: öffnet Editor mit „Quick-Connect“-Vorlage.
|
- Mit Auswahl: verbindet direkt. Ohne Auswahl: öffnet Editor mit „Quick-Connect“-Vorlage.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user