SSH-Agent-Socket an ssh durchreichen (wie Terminal), Banner-Tipp, Doku

This commit is contained in:
x3
2026-09-21 23:47:01 +02:00
parent 37a70edbab
commit ed6e96b3c1
4 changed files with 46 additions and 3 deletions
@@ -42,6 +42,30 @@ enum SSHService {
// 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,