Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

feat(remote-host): add SSH password auth and restyle the settings form

vastsab38dfde6ec6c
diff --git a/apps/desktop/electron/main/bootstrap/remote-hosts.ts b/apps/desktop/electron/main/bootstrap/remote-hosts.ts
index 6b818186b..a9809a0c0 100644
--- a/apps/desktop/electron/main/bootstrap/remote-hosts.ts
+++ b/apps/desktop/electron/main/bootstrap/remote-hosts.ts
@@ -167,6 +167,10 @@ export function sshMetadataOf(record: RemoteHostRecord): RemoteHostSshMetadata |
...(port !== null ? { port } : {}),
...(user !== null ? { user } : {}),
...(identityFile !== null ? { identityFile } : {}),
+ // Anything that is not the literal `"password"` reads back as a key
+ // descriptor, so records written before this field existed are unchanged —
+ // on disk and in memory alike.
+ ...(candidate.auth === "password" ? { auth: "password" as const } : {}),
remotePort: candidate.remotePort,
version: typeof candidate.version === "string" ? candidate.version : "",
};
@@ -179,12 +183,15 @@ export function sshHostRecord(input: {
url: string;
deviceToken: string;
ssh: RemoteHostSshMetadata;
+ /** Login password for a host that uses one; the registry encrypts it. */
+ sshSecret?: string;
}): RemoteHostRecord {
return {
hostKey: input.hostKey,
label: input.label,
url: input.url,
deviceToken: input.deviceToken,
+ ...(input.sshSecret ? { sshSecret: input.sshSecret } : {}),
metadata: { [TRANSPORT_KEY]: "ssh", [SSH_KEY]: input.ssh },
};
}
@@ -247,7 +254,9 @@ export function createRemoteHostsBoot(
const ssh = sshMetadataOf(record);
// An SSH host is only reachable while its forward is up; opening one here
// — rather than trusting the stored URL — is what makes a restart work.
- const url = ssh ? (await tunnels.open(record.hostKey, ssh)).url : record.url;
+ const url = ssh
+ ? (await tunnels.open(record.hostKey, ssh, record.sshSecret)).url
+ : record.url;
try {
const adapter = buildAdapter({ ...record, url });
await adapter.connect();
@@ -398,6 +407,7 @@ export function createRemoteHostsBoot(
url: outcome.url,
deviceToken: outcome.deviceToken,
ssh: outcome.ssh,
+ ...(outcome.sshSecret ? { sshSecret: outcome.sshSecret } : {}),
}),
);
return { host, ssh: outcome.ssh, steps: outcome.steps };
diff --git a/apps/desktop/electron/main/remote/remote-host-registry.ts b/apps/desktop/electron/main/remote/remote-host-registry.ts
index 67f175016..b367438df 100644
--- a/apps/desktop/electron/main/remote/remote-host-registry.ts
+++ b/apps/desktop/electron/main/remote/remote-host-registry.ts
@@ -26,7 +26,7 @@ export interface EncryptionPort {
decryptString(ciphertext: Buffer): string;
}
-/** One paired host as it lives on disk (token stays encrypted at rest). */
+/** One paired host as it lives on disk (every secret stays encrypted at rest). */
export type RemoteHostRecord = {
/** Stable id used in `remote:<hostKey>:<...>` renderer session ids. */
hostKey: string;
@@ -36,19 +36,33 @@ export type RemoteHostRecord = {
url: string;
/** Device token issued at pairing, presented on every reconnect. */
deviceToken: string;
+ /**
+ * SSH login password for a host that authenticates with one instead of a
+ * key. Optional and normally absent. It is the second encrypted-at-rest
+ * value in the record and, unlike `metadata`, it is never handed to the
+ * renderer — the only consumers are the tunnel's `ssh` spawn and the
+ * bootstrap that is about to write it.
+ */
+ sshSecret?: string;
/** Room for later fields (roles, protocol hints) without a schema bump. */
metadata?: Record<string, unknown>;
};
-/** The on-disk record: the plaintext deviceToken is replaced with base64
- * ciphertext + version byte, so a token cannot be recovered without the
- * matching safeStorage keychain. */
+/** The on-disk record: the plaintext secrets are replaced with base64
+ * ciphertext + version byte, so neither can be recovered without the matching
+ * safeStorage keychain. */
type SerializedRecord = {
hostKey: string;
label: string;
url: string;
/** Base64 of the `safeStorage.encryptString` output. */
encryptedDeviceToken: string;
+ /**
+ * Base64 of the encrypted SSH password. Absent for a key-authenticated host
+ * and for every record written before password auth existed, so the file
+ * format needs no version bump.
+ */
+ encryptedSshSecret?: string;
metadata?: Record<string, unknown>;
};
@@ -120,11 +134,29 @@ export function createRemoteHostRegistry(
try {
const buffer = Buffer.from(record.encryptedDeviceToken, "base64");
const deviceToken = options.encryption.decryptString(buffer);
+ // A host whose SSH password will not decrypt still has a usable
+ // device token, and dropping the whole record over it would hide a
+ // paired host from the user. It reads back as "no password", which
+ // is exactly the pre-password-auth behaviour.
+ let sshSecret: string | undefined;
+ if (record.encryptedSshSecret) {
+ try {
+ sshSecret = options.encryption.decryptString(
+ Buffer.from(record.encryptedSshSecret, "base64"),
+ );
+ } catch (error) {
+ log("warn", "remote host ssh credential could not be decrypted; dropping it", {
+ hostKey: record.hostKey,
+ error: String(error),
+ });
+ }
+ }
decoded.push({
hostKey: record.hostKey,
label: record.label,
url: record.url,
deviceToken,
+ ...(sshSecret !== undefined ? { sshSecret } : {}),
...(record.metadata ? { metadata: record.metadata } : {}),
});
} catch (error) {
@@ -153,6 +185,13 @@ export function createRemoteHostRegistry(
label: record.label,
url: record.url,
encryptedDeviceToken: ciphertext,
+ ...(record.sshSecret
+ ? {
+ encryptedSshSecret: options.encryption
+ .encryptString(record.sshSecret)
+ .toString("base64"),
+ }
+ : {}),
...(record.metadata ? { metadata: record.metadata } : {}),
};
const next = file.hosts.filter((existing) => existing.hostKey !== record.hostKey);
diff --git a/apps/desktop/electron/main/remote/ssh-askpass.ts b/apps/desktop/electron/main/remote/ssh-askpass.ts
new file mode 100644
index 000000000..23e4a8ed7
--- /dev/null
+++ b/apps/desktop/electron/main/remote/ssh-askpass.ts
@@ -0,0 +1,146 @@
+/**
+ * OpenSSH's askpass seam: how a login password reaches the `ssh` client
+ * without ever becoming a command-line argument.
+ *
+ * The transport deliberately spawns the system `ssh` (see `ssh-transport.ts`),
+ * which reads a password from the terminal — and there is no terminal behind
+ * that spawn. OpenSSH's own answer is `SSH_ASKPASS`: when it needs a secret it
+ * runs the program named by that variable and reads the first line of its
+ * stdout. This module builds that program.
+ *
+ * Two properties matter, and both are structural rather than conventional:
+ *
+ * - The secret is not an argument and not an environment variable. It lives in
+ * a `0600` file inside a `0700` directory, and the helper reads it by path, so
+ * a process listing (`ps`) never shows it and neither does a crash dump of
+ * the argv.
+ * - The material is created lazily, only when an `ssh` child is about to
+ * authenticate, and deleted again as soon as that child is done with it —
+ * for a forward, that is the moment the port is up. Nothing keeps the file
+ * alive past its use.
+ *
+ * `SSH_ASKPASS_REQUIRE=force` (OpenSSH 8.4+) is what makes this work without a
+ * terminal; `DISPLAY` is set as well because older builds only consult the
+ * helper when there is no tty *and* a display to blame.
+ */
+import { chmod, mkdtemp, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { ErrorCodes } from "@pi-desktop/shared";
+
+/** Environment variable naming the file the helper reads the secret from. */
+export const ASKPASS_SECRET_ENV = "PI_SSH_ASKPASS_SECRET";
+
+/**
+ * The helper. `$1` is OpenSSH's prompt text and is deliberately ignored: the
+ * same secret answers "user@host's password:" and a key passphrase prompt, and
+ * an encrypted key whose passphrase is not this password simply falls through
+ * to password authentication. The trailing `echo` terminates the line OpenSSH
+ * reads, so a secret without a trailing newline is still returned whole.
+ */
+export const ASKPASS_HELPER_SCRIPT = `#!/bin/sh
+# Written by the desktop app; do not edit. Reads the secret from a 0600 file
+# so it never appears in the process list.
+cat "\${${ASKPASS_SECRET_ENV}}"
+echo
+`;
+
+/**
+ * A cap, so a paste of something enormous fails as a validation error instead
+ * of as a mysterious authentication failure.
+ */
+const MAX_PASSWORD_LENGTH = 4096;
+
+function fail(message: string, errorCode: string, data?: Record<string, unknown>): Error {
+ return Object.assign(new Error(message), { errorCode, ...(data ?? {}) });
+}
+
+/** Validate a supplied login password; returns it unchanged. */
+export function assertSshPassword(value: unknown, field = "password"): string {
+ if (typeof value !== "string") {
+ throw fail(`${field} must be a string`, ErrorCodes.INVALID_ARGUMENT, { field });
+ }
+ if (value.length === 0) {
+ throw fail(`${field} must not be empty`, ErrorCodes.INVALID_ARGUMENT, { field });
+ }
+ if (value.length > MAX_PASSWORD_LENGTH) {
+ throw fail(`${field} must be at most ${MAX_PASSWORD_LENGTH} characters`, ErrorCodes.INVALID_ARGUMENT, {
+ field,
+ });
+ }
+ if (/[\r\n]/.test(value)) {
+ // Not a style rule: `ssh` reads the askpass answer up to the first line
+ // break, so anything after one would be silently dropped.
+ throw fail(`${field} must not contain a line break`, ErrorCodes.INVALID_ARGUMENT, { field });
+ }
+ return value;
+}
+
+/** On-disk credential material handed to one `ssh` child at a time. */
+export type SshAskpassMaterial = {
+ /** Variables to merge over `process.env` for the `ssh` spawn. */
+ env: NodeJS.ProcessEnv;
+ /** Delete the secret and the helper. Idempotent. */
+ dispose(): Promise<void>;
+};
+
+export type SshAskpassOptions = {
+ /** Parent directory for the throwaway folder; defaults to the OS temp dir. */
+ dir?: string;
+ /** Injected for tests; defaults to `process.platform`. */
+ platform?: NodeJS.Platform;
+};
+
+/**
+ * Write the secret and the helper to a throwaway directory.
+ *
+ * Windows is refused rather than half-supported: its OpenSSH build cannot
+ * execute a shell-script askpass helper, and shipping a helper executable is a
+ * project of its own. The caller surfaces this as a bootstrap failure naming
+ * the remedy (use a key or the agent), which is better than an authentication
+ * error the user cannot act on.
+ */
+export async function createSshAskpass(
+ secret: unknown,
+ options: SshAskpassOptions = {},
+): Promise<SshAskpassMaterial> {
+ const password = assertSshPassword(secret);
+ const platform = options.platform ?? process.platform;
+ if (platform === "win32") {
+ throw fail(
+ "password authentication is not supported by OpenSSH on Windows; use an SSH key or agent",
+ ErrorCodes.HOST_BOOTSTRAP_FAILED,
+ { platform },
+ );
+ }
+
+ // `mkdtemp` already creates the directory `0700`; the explicit chmod
+ // documents that the secret's confidentiality rests on this mode rather than
+ // on the inherited umask.
+ const dir = await mkdtemp(join(options.dir ?? tmpdir(), "pi-ssh-askpass-"));
+ await chmod(dir, 0o700);
+ const secretPath = join(dir, "secret");
+ const helperPath = join(dir, "askpass.sh");
+ try {
+ await writeFile(secretPath, password, { mode: 0o600 });
+ await writeFile(helperPath, ASKPASS_HELPER_SCRIPT, { mode: 0o700 });
+ } catch (error) {
+ // A half-written credential is still a credential; do not leave it behind.
+ await rm(dir, { recursive: true, force: true }).catch(() => undefined);
+ throw error;
+ }
+ let disposed = false;
+ return {
+ env: {
+ SSH_ASKPASS: helperPath,
+ SSH_ASKPASS_REQUIRE: "force",
+ DISPLAY: process.env.DISPLAY ?? ":0",
+ [ASKPASS_SECRET_ENV]: secretPath,
+ },
+ async dispose() {
+ if (disposed) return;
+ disposed = true;
+ await rm(dir, { recursive: true, force: true });
+ },
+ };
+}
diff --git a/apps/desktop/electron/main/remote/ssh-bootstrap.ts b/apps/desktop/electron/main/remote/ssh-bootstrap.ts
index 519bda73f..345169a25 100644
--- a/apps/desktop/electron/main/remote/ssh-bootstrap.ts
+++ b/apps/desktop/electron/main/remote/ssh-bootstrap.ts
@@ -48,6 +48,7 @@ import {
type SshExecResult,
type SshTransport,
} from "./ssh-transport.js";
+import { assertSshPassword } from "./ssh-askpass.js";
import { racpUrlForLocalPort } from "./ssh-tunnel.js";
/** Progress the Settings surface can render while a bootstrap runs. */
@@ -96,6 +97,12 @@ export type SshBootstrapOutcome = {
url: string;
deviceToken: string;
ssh: RemoteHostSshMetadata;
+ /**
+ * The login password the forward was opened with, when the user chose
+ * password auth. The caller persists it encrypted; it is never placed in
+ * `ssh` (which is echoed back to the renderer) and never logged.
+ */
+ sshSecret?: string;
/** Steps that completed, in order. */
steps: SshBootstrapStep[];
};
@@ -141,6 +148,12 @@ export function sshMetadataFromTarget(target: SshTarget): Omit<RemoteHostSshMeta
...(target.port !== undefined ? { port: target.port } : {}),
...(target.user ? { user: target.user } : {}),
...(target.identityFile ? { identityFile: target.identityFile } : {}),
+ // Only recorded when it is not the default: a key-authenticated descriptor
+ // keeps exactly the shape it had before password auth existed, so no
+ // existing `remote-hosts.json` entry changes on its next write. A later
+ // launch reads the field to know a secret is needed, so it can say so
+ // plainly instead of failing as a bare authentication error.
+ ...(target.password !== undefined ? { auth: "password" as const } : {}),
};
}
@@ -174,6 +187,12 @@ function validateTarget(request: RemoteHostBootstrapRequest): SshTarget {
if (request?.identityFile) {
target.identityFile = assertSshArgument(String(request.identityFile), "identityFile");
}
+ // The one secret in the request. It is validated here rather than trusted
+ // because it cannot survive a line break through the askpass helper, and a
+ // value that cannot work should be refused before a remote script runs.
+ if (request?.password !== undefined && request.password !== null) {
+ target.password = assertSshPassword(request.password);
+ }
return target;
}
@@ -352,8 +371,24 @@ export function createSshBootstrap(deps: SshBootstrapDeps): SshBootstrap {
version: parsed.ready.version,
};
completed = true;
- log("info", "ssh bootstrap completed", { hostKey, url, version: ssh.version });
- return { hostKey, label, forward, url, deviceToken, ssh, steps };
+ log("info", "ssh bootstrap completed", {
+ hostKey,
+ url,
+ version: ssh.version,
+ auth: ssh.auth,
+ });
+ return {
+ hostKey,
+ label,
+ forward,
+ url,
+ deviceToken,
+ ssh,
+ // Handed to the caller to encrypt, never logged and never returned
+ // to the renderer.
+ ...(target.password !== undefined ? { sshSecret: target.password } : {}),
+ steps,
+ };
} finally {
// On success the caller adopts the forward, which is a child of this
// transport — disposing here would tear down the tunnel it just got.
diff --git a/apps/desktop/electron/main/remote/ssh-transport.ts b/apps/desktop/electron/main/remote/ssh-transport.ts
index 1bafafd71..53e117530 100644
--- a/apps/desktop/electron/main/remote/ssh-transport.ts
+++ b/apps/desktop/electron/main/remote/ssh-transport.ts
@@ -9,12 +9,15 @@
* - The user's `~/.ssh/config`, agent, `known_hosts`, and jump hosts apply
* exactly as they do in their terminal, so a machine that is reachable from
* the shell is reachable from the app with no second credential store.
- * - The desktop never holds, prompts for, or persists an SSH secret; there is
- * nothing for the app to leak.
+ * - With no password in hand the desktop holds no SSH secret at all, and
+ * `BatchMode=yes` keeps that honest: a host that needs an interactive
+ * password or passphrase fails immediately with a typed error instead of
+ * hanging behind an invisible prompt.
*
- * `BatchMode=yes` is what keeps that honest: a host that needs an interactive
- * password or passphrase fails immediately with a typed error instead of
- * hanging a modal behind an invisible prompt.
+ * A password can be supplied instead of relying on a key. That is the one case
+ * where the app carries an SSH secret: it reaches the child through OpenSSH's
+ * askpass helper rather than the command line (`ssh-askpass.ts`), and the
+ * caller decides whether it is persisted encrypted for the next launch.
*
* The module is a port so the bootstrap orchestrator can be tested against a
* fake; `createSystemSshTransport` is the only implementation that spawns.
@@ -23,6 +26,7 @@ import { spawn, type ChildProcessWithoutNullStreams } from "node:child_process";
import { createServer, connect } from "node:net";
import { ErrorCodes } from "@pi-desktop/shared";
import { redactBootstrapOutput } from "./pi-host-bootstrap-script.js";
+import { createSshAskpass, type SshAskpassMaterial } from "./ssh-askpass.js";
/** Where to reach a machine over SSH. */
export type SshTarget = {
@@ -30,6 +34,12 @@ export type SshTarget = {
port?: number;
user?: string;
identityFile?: string;
+ /**
+ * Login password, when the user chose password auth over a key. Never placed
+ * in the argv (`ssh-askpass.ts`). Leaving it undefined keeps the key/agent
+ * path byte-for-byte as it was, `BatchMode=yes` included.
+ */
+ password?: string;
};
export type SshExecResult = {
@@ -101,10 +111,13 @@ export function assertSshArgument(value: string, field: string): string {
/** The argv `ssh` receives, minus the final command. */
export function sshCommonArgs(target: SshTarget): string[] {
+ const password = target.password !== undefined;
const args = [
- // Fail instead of prompting: there is no terminal behind this spawn.
+ // Fail instead of prompting when there is no secret to answer with: there
+ // is no terminal behind this spawn. With one, the prompt is routed to the
+ // askpass helper instead, which is the only reason BatchMode is relaxed.
"-o",
- "BatchMode=yes",
+ password ? "BatchMode=no" : "BatchMode=yes",
// Trust-on-first-use, as `ssh` itself offers interactively.
"-o",
"StrictHostKeyChecking=accept-new",
@@ -114,6 +127,12 @@ export function sshCommonArgs(target: SshTarget): string[] {
"-o",
"ExitOnForwardFailure=yes",
];
+ if (password) {
+ // The helper answers every prompt with the same secret, so a retry could
+ // only repeat a wrong password — and repeated failures are what trip a
+ // server's own lockout. One prompt, one answer.
+ args.push("-o", "NumberOfPasswordPrompts=1");
+ }
if (target.port !== undefined) args.push("-p", String(target.port));
if (target.identityFile) args.push("-i", target.identityFile);
const user = target.user?.trim();
@@ -206,6 +225,8 @@ function runCommand(
options: {
input?: string;
timeoutMs: number;
+ /** Full environment for the child; defaults to the app's own. */
+ env?: NodeJS.ProcessEnv;
/** Called with the spawned child so a transport can track and reap it. */
onSpawn?: (child: ChildProcessWithoutNullStreams) => void;
},
@@ -213,7 +234,7 @@ function runCommand(
return new Promise((resolveRun, rejectRun) => {
let child: ChildProcessWithoutNullStreams;
try {
- child = spawn(binary, args, { stdio: ["pipe", "pipe", "pipe"] });
+ child = spawn(binary, args, { stdio: ["pipe", "pipe", "pipe"], env: options.env });
} catch (error) {
rejectRun(
fail(
@@ -276,13 +297,43 @@ export function createSystemSshTransport(
target: SshTarget,
options: SystemSshTransportOptions = {},
): SshTransport {
- const binary = options.binary ?? "ssh";
const log = options.log ?? (() => undefined);
+ const binary = options.binary ?? "ssh";
const base = [...sshCommonArgs(target), ...(options.extraOptions ?? [])];
const children = new Set<ChildProcessWithoutNullStreams>();
- const spawnTracked = (args: string[]): ChildProcessWithoutNullStreams => {
- const child = spawn(binary, args, { stdio: ["pipe", "pipe", "pipe"] });
+ // Askpass material is written on the first spawn and dropped once no child
+ // can still be authenticating. The reference count is what makes a transport
+ // that runs several commands (`exec`, `execWithInput`, then `forward`) work
+ // without either deleting the secret under a live prompt or keeping it on
+ // disk for the whole session.
+ let material: Promise<SshAskpassMaterial> | null = null;
+ let holders = 0;
+ const acquireEnv = async (): Promise<NodeJS.ProcessEnv | undefined> => {
+ if (target.password === undefined) return undefined;
+ holders += 1;
+ try {
+ material ??= createSshAskpass(target.password);
+ return { ...process.env, ...(await material).env };
+ } catch (error) {
+ holders -= 1;
+ throw error;
+ }
+ };
+ const releaseEnv = async (): Promise<void> => {
+ if (target.password === undefined) return;
+ holders -= 1;
+ if (holders > 0 || !material) return;
+ const current = material;
+ material = null;
+ await current.then((loaded) => loaded.dispose()).catch(() => undefined);
+ };
+
+ const spawnTracked = (
+ args: string[],
+ env?: NodeJS.ProcessEnv,
+ ): ChildProcessWithoutNullStreams => {
+ const child = spawn(binary, args, { stdio: ["pipe", "pipe", "pipe"], env });
children.add(child);
child.once("close", () => children.delete(child));
child.once("error", () => children.delete(child));
@@ -297,15 +348,23 @@ export function createSystemSshTransport(
// `sh -s` reads the script from stdin, so the script never has to survive
// an argv round trip and never lands in a remote file we must clean up.
const args = input === undefined ? [...base, command] : [...base, "sh -s"];
- const result = await runCommand(binary, args, {
- input,
- timeoutMs,
- onSpawn: (child) => {
- children.add(child);
- child.once("close", () => children.delete(child));
- child.once("error", () => children.delete(child));
- },
- });
+ const env = await acquireEnv();
+ let result: SshExecResult;
+ try {
+ result = await runCommand(binary, args, {
+ input,
+ timeoutMs,
+ env,
+ onSpawn: (child) => {
+ children.add(child);
+ child.once("close", () => children.delete(child));
+ child.once("error", () => children.delete(child));
+ },
+ });
+ } finally {
+ // The child has authenticated by now, or it never will.
+ await releaseEnv();
+ }
if (result.code !== 0) {
throw fail(
`ssh command failed with exit code ${result.code}`,
@@ -329,13 +388,14 @@ export function createSystemSshTransport(
execWithInput: (command, input, execOptions) =>
execOnce(command, input, execOptions?.timeoutMs ?? DEFAULT_EXEC_TIMEOUT_MS),
async forward({ localPort, remoteHost, remotePort, timeoutMs }) {
+ const env = await acquireEnv();
const args = [
...base,
"-N",
"-L",
`127.0.0.1:${localPort}:${remoteHost}:${remotePort}`,
];
- const child = spawnTracked(args);
+ const child = spawnTracked(args, env);
let stderr = "";
child.stderr.on("data", (chunk: Buffer) => {
stderr += chunk.toString("utf8");
@@ -393,6 +453,7 @@ export function createSystemSshTransport(
// to its own deadline with a referenced timer.
probeAbort.abort();
child.kill("SIGKILL");
+ await releaseEnv();
throw error instanceof Error && "errorCode" in error
? error
: fail(
@@ -400,7 +461,10 @@ export function createSystemSshTransport(
ErrorCodes.REMOTE_FORWARD_FAILED,
);
}
-
+ // The forward is up, so authentication is over: the askpass helper has
+ // answered its last prompt and the secret file has no further use. The
+ // `ssh` process stays for the life of the tunnel, but without it.
+ await releaseEnv();
let disposed = false;
return {
localPort,
@@ -426,6 +490,12 @@ export function createSystemSshTransport(
dispose() {
for (const child of children) child.kill("SIGKILL");
children.clear();
+ // Killing the children means nothing can still be authenticating, so the
+ // credential files go too rather than waiting out the session.
+ holders = 0;
+ const current = material;
+ material = null;
+ void current?.then((loaded) => loaded.dispose()).catch(() => undefined);
log("info", "ssh transport disposed", { host: target.host });
},
};
diff --git a/apps/desktop/electron/main/remote/ssh-tunnel.ts b/apps/desktop/electron/main/remote/ssh-tunnel.ts
index 0ae15aefa..e7d85b53b 100644
--- a/apps/desktop/electron/main/remote/ssh-tunnel.ts
+++ b/apps/desktop/electron/main/remote/ssh-tunnel.ts
@@ -25,13 +25,21 @@ export function racpUrlForLocalPort(port: number): string {
return `ws://127.0.0.1:${port}${RACP_WS_PATH}`;
}
-/** Translate a persisted descriptor into `ssh` arguments. */
-export function sshTargetOf(ssh: RemoteHostSshMetadata): SshTarget {
+/**
+ * Translate a persisted descriptor into `ssh` arguments.
+ *
+ * `sshSecret` is the login password read back from the encrypted record and is
+ * deliberately not part of {@link RemoteHostSshMetadata}: the descriptor is
+ * plaintext metadata that the renderer also receives, so the secret travels
+ * beside it rather than inside it.
+ */
+export function sshTargetOf(ssh: RemoteHostSshMetadata, sshSecret?: string): SshTarget {
return {
host: ssh.host,
...(ssh.port !== undefined ? { port: ssh.port } : {}),
...(ssh.user ? { user: ssh.user } : {}),
...(ssh.identityFile ? { identityFile: ssh.identityFile } : {}),
+ ...(sshSecret ? { password: sshSecret } : {}),
};
}
@@ -45,17 +53,21 @@ export type SshTunnelManagerOptions = {
/**
* Build the transport for one host. Defaults to the system `ssh` client,
* which is what makes the user's own `~/.ssh/config` and agent apply; tests
- * substitute a fake so no process is spawned.
+ * substitute a fake so no process is spawned. The second argument is the
+ * decrypted login password, absent for a key-authenticated host.
*/
- buildTransport?: (ssh: RemoteHostSshMetadata) => SshTransport;
+ buildTransport?: (ssh: RemoteHostSshMetadata, sshSecret?: string) => SshTransport;
/** Reserve the loopback port `-L` binds. Injectable for deterministic tests. */
reservePort?: () => Promise<number>;
log?: (level: "info" | "warn" | "error", message: string, data?: unknown) => void;
};
export interface SshTunnelManager {
- /** Open the forward for `hostKey`, or return the live one. */
- open(hostKey: string, ssh: RemoteHostSshMetadata): Promise<SshTunnel>;
+ /**
+ * Open the forward for `hostKey`, or return the live one. `sshSecret` is the
+ * decrypted login password when the host authenticates with one.
+ */
+ open(hostKey: string, ssh: RemoteHostSshMetadata, sshSecret?: string): Promise<SshTunnel>;
/** Take ownership of a forward the bootstrap already opened. */
adopt(hostKey: string, ssh: RemoteHostSshMetadata, forward: SshForward): Promise<SshTunnel>;
/** Close the forward for one host; a missing key is a no-op. */
@@ -75,8 +87,8 @@ export function createSshTunnelManager(options: SshTunnelManagerOptions = {}): S
const log = options.log ?? (() => undefined);
const buildTransport =
options.buildTransport ??
- ((ssh: RemoteHostSshMetadata) =>
- createSystemSshTransport(sshTargetOf(ssh), {
+ ((ssh: RemoteHostSshMetadata, sshSecret?: string) =>
+ createSystemSshTransport(sshTargetOf(ssh, sshSecret), {
log: (level, message, data) => log(level, message, data),
}));
const reservePort = options.reservePort ?? reserveLocalPort;
@@ -91,13 +103,17 @@ export function createSshTunnelManager(options: SshTunnelManagerOptions = {}): S
entry.transport.dispose();
};
- const remember = (hostKey: string, ssh: RemoteHostSshMetadata, transport: SshTransport, forward: SshForward): SshTunnel => {
+ const remember = (
+ hostKey: string,
+ ssh: RemoteHostSshMetadata,
+ transport: SshTransport,
+ forward: SshForward,
+ ): SshTunnel => {
const tunnel: SshTunnel = { url: racpUrlForLocalPort(forward.localPort), localPort: forward.localPort };
entries.set(hostKey, { ssh, transport, forward, tunnel });
return tunnel;
};
-
/** Drop one entry and reap its process; shared by `close` and `adopt`. */
const closeForKey = async (hostKey: string): Promise<void> => {
const entry = entries.get(hostKey);
@@ -105,12 +121,13 @@ export function createSshTunnelManager(options: SshTunnelManagerOptions = {}): S
entries.delete(hostKey);
await closeEntry(entry);
};
+
return {
- async open(hostKey, ssh) {
+ async open(hostKey, ssh, sshSecret) {
const existing = entries.get(hostKey);
if (existing) return existing.tunnel;
- const transport = buildTransport(ssh);
+ const transport = buildTransport(ssh, sshSecret);
// A dead ssh client must not take the app with it; `forward` reports the
// failure through its own rejection.
let forward: SshForward;
diff --git a/apps/desktop/src/components/icons.tsx b/apps/desktop/src/components/icons.tsx
index b548bd59c..9426062f1 100644
--- a/apps/desktop/src/components/icons.tsx
+++ b/apps/desktop/src/components/icons.tsx
@@ -30,6 +30,8 @@ import {
Copy,
Dot,
ExternalLink,
+ Eye,
+ EyeOff,
FileDiff,
FileSpreadsheet,
FileText,
@@ -240,6 +242,9 @@ export const IconStar = icon(Star);
export const IconCircleCheck = icon(CircleCheck);
export const IconCircleAlert = icon(CircleAlert);
export const IconTriangleAlert = icon(TriangleAlert);
+/* Password field reveal toggle (see PasswordInput). */
+export const IconEye = icon(Eye);
+export const IconEyeOff = icon(EyeOff);
export function IconStop({ size = 16, style, ...props }: IconProps) {
return (
diff --git a/apps/desktop/src/components/settings/RemoteHostsPage.tsx b/apps/desktop/src/components/settings/RemoteHostsPage.tsx
index 4b962ee47..d7ee5a395 100644
--- a/apps/desktop/src/components/settings/RemoteHostsPage.tsx
+++ b/apps/desktop/src/components/settings/RemoteHostsPage.tsx
@@ -7,13 +7,17 @@
* pairing token issued by the target `pi-host`. The renderer never sees a
* device token — pairing exchange and encrypted persistence stay inside
* Electron main.
+ *
+ * Cards run from the common path to the advanced one: install over SSH first,
+ * pairing a URL + token by hand last. A password typed into the SSH form lives
+ * in this component's state only; it is never persisted or logged here.
*/
import { useCallback, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
-import type { RemoteHostSummary } from "@pi-desktop/shared";
+import type { RemoteHostSshAuth, RemoteHostSummary } from "@pi-desktop/shared";
import { api } from "../../lib/api";
import { useAppStore } from "../../stores/app-store";
-import { Input, cx } from "../ui";
+import { Badge, Button, Field, Input, PasswordInput, cx } from "../ui";
import { SettingsCard, SettingsRow } from "../../features/settings/primitives";
type PairForm = {
@@ -30,6 +34,8 @@ type SshForm = {
user: string;
port: string;
identityFile: string;
+ auth: RemoteHostSshAuth;
+ password: string;
};
const EMPTY_SSH_FORM: SshForm = {
@@ -38,6 +44,8 @@ const EMPTY_SSH_FORM: SshForm = {
user: "",
port: "",
identityFile: "",
+ auth: "key",
+ password: "",
};
export function RemoteHostsPage() {
@@ -110,29 +118,47 @@ export function RemoteHostsPage() {
[refresh, showToast, t],
);
+ // Switching back to a key drops the secret from the draft: it is only ever
+ // held while password mode is selected.
+ const selectSshAuth = useCallback((auth: RemoteHostSshAuth) => {
+ setSshForm((prev) => ({
+ ...prev,
+ auth,
+ password: auth === "key" ? "" : prev.password,
+ }));
+ }, []);
+
const submitSsh = useCallback(
async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
const label = sshForm.label.trim();
const host = sshForm.host.trim();
if (!host || !label) return;
+ const passwordMode = sshForm.auth === "password";
+ // Never trimmed: leading and trailing spaces can be part of a password,
+ // so emptiness is tested separately from the value that is sent.
+ const password = sshForm.password;
+ if (passwordMode && !password) return;
const user = sshForm.user.trim();
- const identityFile = sshForm.identityFile.trim();
const port = sshForm.port.trim();
+ const identityFile = sshForm.identityFile.trim();
setInstalling(true);
try {
// Empty optional fields are dropped rather than sent blank, so main
- // falls back to the SSH config and the local user name.
+ // falls back to the SSH config and the local user name. A password
+ // replaces the key, so no `-i` is sent alongside it.
const result = await api.bootstrapRemoteHost({
label,
host,
...(user ? { user } : {}),
- ...(identityFile ? { identityFile } : {}),
...(port ? { port: Number(port) } : {}),
+ ...(!passwordMode && identityFile ? { identityFile } : {}),
+ ...(passwordMode && password ? { password } : {}),
});
showToast(t("settings.remoteHosts.sshSucceeded", { label: result.host.label }), {
variant: "info",
});
+ // Drops the password with the rest of the draft.
setSshForm(EMPTY_SSH_FORM);
await refresh();
} catch (caught) {
@@ -145,6 +171,12 @@ export function RemoteHostsPage() {
[sshForm, refresh, showToast, t],
);
+ const sshSubmitDisabled =
+ installing ||
+ !sshForm.host.trim() ||
+ !sshForm.label.trim() ||
+ (sshForm.auth === "password" && sshForm.password === "");
+
return (
<div className="settings-stack">
<SettingsCard title={t("settings.remoteHosts.listTitle")}>
@@ -173,40 +205,214 @@ export function RemoteHostsPage() {
title={host.label}
description={
<span className="font-mono text-xs-plus text-text-muted">
- {host.transport === "ssh" ? "ssh · " : ""}
+ {host.transport === "ssh"
+ ? `${t("settings.remoteHosts.transportSsh")} · `
+ : ""}
{host.url}
</span>
}
>
<span
- className={cx(
- "settings-remote-host-status",
- host.connected ? "is-online" : "is-offline",
- )}
+ className="settings-remote-host-status"
role="status"
aria-live="polite"
>
- {host.connected
- ? t("settings.remoteHosts.statusOnline")
- : t("settings.remoteHosts.statusOffline")}
+ <Badge tone={host.connected ? "success" : "neutral"}>
+ {host.connected
+ ? t("settings.remoteHosts.statusOnline")
+ : t("settings.remoteHosts.statusOffline")}
+ </Badge>
</span>
- <button
+ <Button
+ variant="ghost"
type="button"
- className="settings-button danger"
disabled={removing === host.hostKey}
onClick={() => void remove(host)}
>
{removing === host.hostKey
? t("settings.remoteHosts.removing")
: t("settings.remoteHosts.remove")}
- </button>
+ </Button>
</SettingsRow>
))
)}
</SettingsCard>
+ <SettingsCard title={t("settings.remoteHosts.sshTitle")}>
+ <div className="settings-row-copy" role="note">
+ <div className="settings-row-desc">{t("settings.remoteHosts.sshBody")}</div>
+ </div>
+ <form onSubmit={submitSsh} className="settings-remote-host-form">
+ <div className="settings-remote-host-form-row">
+ <Field
+ label={t("settings.remoteHosts.fieldLabel")}
+ hint={t("settings.remoteHosts.fieldLabelDesc")}
+ >
+ <Input
+ value={sshForm.label}
+ onChange={(event) =>
+ setSshForm((prev) => ({ ...prev, label: event.target.value }))
+ }
+ placeholder={t("settings.remoteHosts.fieldLabelPlaceholder")}
+ aria-label={t("settings.remoteHosts.fieldLabel")}
+ autoComplete="off"
+ spellCheck={false}
+ disabled={installing}
+ />
+ </Field>
+ <Field
+ label={t("settings.remoteHosts.sshHost")}
+ hint={t("settings.remoteHosts.sshHostDesc")}
+ >
+ <Input
+ value={sshForm.host}
+ onChange={(event) =>
+ setSshForm((prev) => ({ ...prev, host: event.target.value }))
+ }
+ placeholder={t("settings.remoteHosts.sshHostPlaceholder")}
+ aria-label={t("settings.remoteHosts.sshHost")}
+ autoComplete="off"
+ autoCapitalize="off"
+ spellCheck={false}
+ disabled={installing}
+ />
+ </Field>
+ </div>
+
+ <div className="settings-remote-host-form-row is-narrow-port">
+ <Field
+ label={t("settings.remoteHosts.sshUser")}
+ hint={t("settings.remoteHosts.sshUserDesc")}
+ >
+ <Input
+ value={sshForm.user}
+ onChange={(event) =>
+ setSshForm((prev) => ({ ...prev, user: event.target.value }))
+ }
+ aria-label={t("settings.remoteHosts.sshUser")}
+ autoComplete="off"
+ autoCapitalize="off"
+ spellCheck={false}
+ disabled={installing}
+ />
+ </Field>
+ <Field
+ label={t("settings.remoteHosts.sshPort")}
+ hint={t("settings.remoteHosts.sshPortDesc")}
+ >
+ <Input
+ value={sshForm.port}
+ onChange={(event) =>
+ setSshForm((prev) => ({ ...prev, port: event.target.value }))
+ }
+ aria-label={t("settings.remoteHosts.sshPort")}
+ inputMode="numeric"
+ autoComplete="off"
+ spellCheck={false}
+ disabled={installing}
+ />
+ </Field>
+ </div>
+
+ <div className="settings-remote-host-form-auth">
+ <div
+ className="text-sm text-text-secondary"
+ id="settings-remote-host-auth-label"
+ >
+ {t("settings.remoteHosts.sshAuthMode")}
+ </div>
+ <div
+ className="settings-segment"
+ role="radiogroup"
+ aria-labelledby="settings-remote-host-auth-label"
+ aria-describedby="settings-remote-host-auth-desc"
+ >
+ {(["key", "password"] as const).map((auth) => (
+ <button
+ key={auth}
+ type="button"
+ role="radio"
+ className={cx(
+ "settings-segment-item",
+ sshForm.auth === auth && "active",
+ )}
+ aria-checked={sshForm.auth === auth}
+ aria-pressed={sshForm.auth === auth}
+ disabled={installing}
+ onClick={() => selectSshAuth(auth)}
+ >
+ {auth === "key"
+ ? t("settings.remoteHosts.sshAuthKey")
+ : t("settings.remoteHosts.sshAuthPassword")}
+ </button>
+ ))}
+ </div>
+ <div
+ className="text-xs text-text-muted"
+ id="settings-remote-host-auth-desc"
+ >
+ {t("settings.remoteHosts.sshAuthModeDesc")}
+ </div>
+ </div>
+
+ {sshForm.auth === "key" ? (
+ <Field
+ label={t("settings.remoteHosts.sshIdentityFile")}
+ hint={t("settings.remoteHosts.sshIdentityFileDesc")}
+ >
+ <Input
+ value={sshForm.identityFile}
+ onChange={(event) =>
+ setSshForm((prev) => ({ ...prev, identityFile: event.target.value }))
+ }
+ aria-label={t("settings.remoteHosts.sshIdentityFile")}
+ autoComplete="off"
+ autoCapitalize="off"
+ spellCheck={false}
+ disabled={installing}
+ />
+ </Field>
+ ) : (
+ <Field
+ label={t("settings.remoteHosts.sshPassword")}
+ hint={`${t("settings.remoteHosts.sshPasswordDesc")} ${t(
+ "settings.remoteHosts.sshPasswordStored",
+ )}`}
+ >
+ <PasswordInput
+ value={sshForm.password}
+ onChange={(event) =>
+ setSshForm((prev) => ({ ...prev, password: event.target.value }))
+ }
+ placeholder={t("settings.remoteHosts.sshPasswordPlaceholder")}
+ aria-label={t("settings.remoteHosts.sshPassword")}
+ autoComplete="off"
+ spellCheck={false}
+ disabled={installing}
+ showLabel={t("settings.remoteHosts.sshShowPassword")}
+ hideLabel={t("settings.remoteHosts.sshHidePassword")}
+ />
+ </Field>
+ )}
+
+ <div className="settings-remote-host-form-actions">
+ <span className="text-xs text-text-muted">
+ {t("settings.remoteHosts.sshActionHint")}
+ </span>
+ <Button type="submit" variant="primary" disabled={sshSubmitDisabled}>
+ {installing
+ ? t("settings.remoteHosts.sshRunning")
+ : t("settings.remoteHosts.sshAction")}
+ </Button>
+ </div>
+ </form>
+ </SettingsCard>
+
<SettingsCard title={t("settings.remoteHosts.pairTitle")}>
- <form onSubmit={submit} className="settings-remote-host-form">
+ <div className="settings-row-copy" role="note">
+ <div className="settings-row-desc">{t("settings.remoteHosts.pairBody")}</div>
+ </div>
+ <form onSubmit={submit}>
<SettingsRow
title={t("settings.remoteHosts.fieldLabel")}
description={t("settings.remoteHosts.fieldLabelDesc")}
@@ -260,9 +466,9 @@ export function RemoteHostsPage() {
/>
</SettingsRow>
<SettingsRow title={t("settings.remoteHosts.pairAction")}>
- <button
+ <Button
type="submit"
- className="settings-button primary"
+ variant="primary"
disabled={
pairing ||
!form.url.trim() ||
@@ -273,110 +479,10 @@ export function RemoteHostsPage() {
{pairing
? t("settings.remoteHosts.pairing")
: t("settings.remoteHosts.pair")}
- </button>
- </SettingsRow>
- </form>
-
- <SettingsCard title={t("settings.remoteHosts.sshTitle")}>
- <div className="settings-row-copy" role="note">
- <div className="settings-row-desc">{t("settings.remoteHosts.sshBody")}</div>
- </div>
- <form onSubmit={submitSsh} className="settings-remote-host-form">
- <SettingsRow
- title={t("settings.remoteHosts.fieldLabel")}
- description={t("settings.remoteHosts.fieldLabelDesc")}
- >
- <Input
- value={sshForm.label}
- onChange={(event) =>
- setSshForm((prev) => ({ ...prev, label: event.target.value }))
- }
- placeholder={t("settings.remoteHosts.fieldLabelPlaceholder")}
- aria-label={t("settings.remoteHosts.fieldLabel")}
- autoComplete="off"
- spellCheck={false}
- disabled={installing}
- />
- </SettingsRow>
- <SettingsRow
- title={t("settings.remoteHosts.sshHost")}
- description={t("settings.remoteHosts.sshHostDesc")}
- >
- <Input
- value={sshForm.host}
- onChange={(event) =>
- setSshForm((prev) => ({ ...prev, host: event.target.value }))
- }
- placeholder={t("settings.remoteHosts.sshHostPlaceholder")}
- aria-label={t("settings.remoteHosts.sshHost")}
- autoComplete="off"
- autoCapitalize="off"
- spellCheck={false}
- disabled={installing}
- />
- </SettingsRow>
- <SettingsRow
- title={t("settings.remoteHosts.sshUser")}
- description={t("settings.remoteHosts.sshUserDesc")}
- >
- <Input
- value={sshForm.user}
- onChange={(event) =>
- setSshForm((prev) => ({ ...prev, user: event.target.value }))
- }
- aria-label={t("settings.remoteHosts.sshUser")}
- autoComplete="off"
- autoCapitalize="off"
- spellCheck={false}
- disabled={installing}
- />
- </SettingsRow>
- <SettingsRow
- title={t("settings.remoteHosts.sshPort")}
- description={t("settings.remoteHosts.sshPortDesc")}
- >
- <Input
- value={sshForm.port}
- onChange={(event) =>
- setSshForm((prev) => ({ ...prev, port: event.target.value }))
- }
- aria-label={t("settings.remoteHosts.sshPort")}
- inputMode="numeric"
- autoComplete="off"
- spellCheck={false}
- disabled={installing}
- />
- </SettingsRow>
- <SettingsRow
- title={t("settings.remoteHosts.sshIdentityFile")}
- description={t("settings.remoteHosts.sshIdentityFileDesc")}
- >
- <Input
- value={sshForm.identityFile}
- onChange={(event) =>
- setSshForm((prev) => ({ ...prev, identityFile: event.target.value }))
- }
- aria-label={t("settings.remoteHosts.sshIdentityFile")}
- autoComplete="off"
- autoCapitalize="off"
- spellCheck={false}
- disabled={installing}
- />
- </SettingsRow>
- <SettingsRow title={t("settings.remoteHosts.sshAction")}>
- <button
- type="submit"
- className="settings-button primary"
- disabled={installing || !sshForm.host.trim() || !sshForm.label.trim()}
- >
- {installing
- ? t("settings.remoteHosts.sshRunning")
- : t("settings.remoteHosts.sshAction")}
- </button>
+ </Button>
</SettingsRow>
</form>
</SettingsCard>
- </SettingsCard>
</div>
);
}
diff --git a/apps/desktop/src/components/ui.tsx b/apps/desktop/src/components/ui.tsx
index 0030e632c..da93bba2a 100644
--- a/apps/desktop/src/components/ui.tsx
+++ b/apps/desktop/src/components/ui.tsx
@@ -12,6 +12,8 @@ import {
type TextareaHTMLAttributes,
} from "react";
+import { IconEye, IconEyeOff } from "./icons";
+
export function cx(...parts: Array<string | false | null | undefined>) {
return parts.filter(Boolean).join(" ");
}
@@ -538,6 +540,40 @@ export function Input({
);
}
+export function PasswordInput({
+ showLabel,
+ hideLabel,
+ className,
+ disabled,
+ ...props
+}: InputHTMLAttributes<HTMLInputElement> & {
+ /** Localized `aria-label` for the reveal control; the caller passes `t(...)`. */
+ showLabel: string;
+ hideLabel: string;
+}) {
+ const [revealed, setRevealed] = useState(false);
+ return (
+ <span className="password-input">
+ <Input
+ {...props}
+ className={className}
+ disabled={disabled}
+ type={revealed ? "text" : "password"}
+ />
+ <button
+ type="button"
+ className="password-input-toggle"
+ aria-label={revealed ? hideLabel : showLabel}
+ aria-pressed={revealed}
+ disabled={disabled}
+ onClick={() => setRevealed((current) => !current)}
+ >
+ {revealed ? <IconEyeOff /> : <IconEye />}
+ </button>
+ </span>
+ );
+}
+
export function Textarea({ className, spellCheck = false, autoCorrect = "off", autoCapitalize = "off", ...props }: TextareaHTMLAttributes<HTMLTextAreaElement>) {
return (
<textarea
diff --git a/apps/desktop/src/lib/settings-search.ts b/apps/desktop/src/lib/settings-search.ts
index dc7f6ba47..bd704b9c0 100644
--- a/apps/desktop/src/lib/settings-search.ts
+++ b/apps/desktop/src/lib/settings-search.ts
@@ -239,6 +239,10 @@ export const SETTINGS_NAV: SettingsNavEntry[] = [
"settings.remoteHosts.pair",
"settings.remoteHosts.fieldUrl",
"settings.remoteHosts.fieldPairingToken",
+ "settings.remoteHosts.sshTitle",
+ "settings.remoteHosts.sshHost",
+ "settings.remoteHosts.sshAuthMode",
+ "settings.remoteHosts.sshPassword",
"settings.remoteHosts.statusOnline",
"settings.remoteHosts.statusOffline",
],
diff --git a/apps/desktop/src/styles/settings.css b/apps/desktop/src/styles/settings.css
index ade466d32..086c4dccb 100644
--- a/apps/desktop/src/styles/settings.css
+++ b/apps/desktop/src/styles/settings.css
@@ -441,6 +441,67 @@
padding: 12px 14px 14px;
}
+/*
+ Remote hosts: the SSH install is a real form (label + field cells), not a row
+ list, so it keeps the rhythm of `.settings-form-grid` and lays its fields out
+ in a two-column grid instead of five stacked full-width rows.
+*/
+.settings-remote-host-form {
+ display: grid;
+ gap: 12px;
+ padding: 12px 14px 14px;
+}
+
+/* Label + host. The port only needs room for five digits, so the user row
+ trades its second column for a narrow one. */
+.settings-remote-host-form-row {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 12px;
+}
+
+.settings-remote-host-form-row.is-narrow-port {
+ grid-template-columns: minmax(0, 1fr) minmax(120px, 0.4fr);
+}
+
+/* Authentication mode: label, the shared segmented control, and its note.
+ The segment keeps its paint from `.settings-segment` and only takes its
+ position from here. */
+.settings-remote-host-form-auth {
+ display: grid;
+ gap: 6px;
+ justify-items: start;
+}
+
+/* The install action sits right; its hint stays with it on the left. */
+.settings-remote-host-form-actions {
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
+ flex-wrap: wrap;
+ gap: 12px;
+}
+
+/* Paired-host row: the status pill and the remove action need a gap, which the
+ row's control column does not have by default. */
+.settings-row-control:has(> .settings-remote-host-status) {
+ gap: 10px;
+}
+
+.settings-remote-host-status {
+ display: inline-flex;
+ align-items: center;
+}
+
+/* Same breakpoint as the other two-column grid in this sheet
+ (`.plugin-scenic-theme-grid`): one field per row before the columns pinch. */
+@media (max-width: 720px) {
+ .settings-remote-host-form-row,
+ .settings-remote-host-form-row.is-narrow-port {
+ grid-template-columns: minmax(0, 1fr);
+ }
+}
+
.settings-row {
display: flex;
align-items: center;
diff --git a/apps/desktop/src/styles/ui-kit.css b/apps/desktop/src/styles/ui-kit.css
index 623188b52..ab41eca78 100644
--- a/apps/desktop/src/styles/ui-kit.css
+++ b/apps/desktop/src/styles/ui-kit.css
@@ -61,6 +61,39 @@
cursor: default;
}
+/* A password field with a reveal control: the toggle rides inside the field's
+ own row so the two read as one control (PasswordInput). */
+.password-input {
+ position: relative;
+ display: flex;
+ align-items: center;
+}
+
+/* Room for the toggle, which is positioned over the well's trailing edge. */
+.password-input .field-input {
+ padding-right: 34px;
+}
+
+.password-input-toggle {
+ position: absolute;
+ right: 4px;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: var(--ds-control-size);
+ height: var(--ds-control-size);
+ border-radius: var(--radius-sm);
+ color: var(--ds-text-secondary);
+ transition:
+ background var(--motion-duration-fast) var(--motion-ease-out),
+ color var(--motion-duration-fast) var(--motion-ease-out);
+}
+
+.password-input-toggle:hover:not(:disabled) {
+ background: var(--ds-bg-hover);
+ color: var(--ds-text-primary);
+}
+
.btn {
display: inline-flex;
align-items: center;
diff --git a/apps/desktop/test/remote-host-ssh-password.test.mjs b/apps/desktop/test/remote-host-ssh-password.test.mjs
new file mode 100644
index 000000000..c9e959cbb
--- /dev/null
+++ b/apps/desktop/test/remote-host-ssh-password.test.mjs
@@ -0,0 +1,364 @@
+/**
+ * SSH password authentication, end to end across the seams that carry it.
+ *
+ * Three properties are load-bearing and each is asserted here rather than
+ * assumed:
+ *
+ * 1. The secret never becomes an `ssh` argument. It reaches the child through
+ * the askpass helper's `0600` file, and the argv of a password spawn must
+ * still show exactly the options a key spawn shows, plus the two that make
+ * the helper usable.
+ * 2. The credential material is short-lived: written when a child is about to
+ * authenticate and gone once it is not.
+ * 3. It survives a restart by being persisted encrypted, and a record written
+ * before password auth existed keeps working unchanged.
+ *
+ * Fixture executables and a fake `EncryptionPort` keep every case offline.
+ */
+import assert from "node:assert/strict";
+import test from "node:test";
+import { chmod, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
+import { register } from "node:module";
+import { tmpdir } from "node:os";
+import { dirname, join } from "node:path";
+import { fileURLToPath, pathToFileURL } from "node:url";
+
+const here = dirname(fileURLToPath(import.meta.url));
+register(pathToFileURL(join(here, "helpers/ts-import-hooks.mjs")));
+
+const {
+ ASKPASS_HELPER_SCRIPT,
+ ASKPASS_SECRET_ENV,
+ assertSshPassword,
+ createSshAskpass,
+} = await import("../electron/main/remote/ssh-askpass.ts");
+const { createSystemSshTransport, sshCommonArgs } = await import(
+ "../electron/main/remote/ssh-transport.ts"
+);
+const { sshTargetOf } = await import("../electron/main/remote/ssh-tunnel.ts");
+const { createRemoteHostRegistry } = await import(
+ "../electron/main/remote/remote-host-registry.ts"
+);
+const { sshHostRecord, sshMetadataOf, transportOf } = await import(
+ "../electron/main/bootstrap/remote-hosts.ts"
+);
+
+const TEST_TIMEOUT_MS = 20_000;
+const PASSWORD = "correct horse battery staple";
+
+/** Reversible fake keychain: the prefix proves the value went through encrypt. */
+function fakeEncryption(overrides = {}) {
+ return {
+ available: overrides.available ?? true,
+ isAvailable() {
+ return this.available;
+ },
+ encryptString(plain) {
+ return Buffer.from(`enc:${plain}`);
+ },
+ decryptString(buffer) {
+ const text = buffer.toString("utf8");
+ if (!text.startsWith("enc:")) throw new Error("cannot decrypt");
+ return text.slice("enc:".length);
+ },
+ };
+}
+
+async function tmpDir(t, prefix = "ssh-password-") {
+ const dir = await mkdtemp(join(tmpdir(), prefix));
+ t.after(() => rm(dir, { recursive: true, force: true }));
+ return dir;
+}
+
+/** Write an executable fixture and clean it up with its test. */
+async function writeFixture(t, body, name) {
+ const dir = await tmpDir(t, "ssh-fixture-");
+ const path = join(dir, name);
+ await writeFile(path, body, { mode: 0o700 });
+ await chmod(path, 0o700);
+ t.after(() => rm(path, { force: true }));
+ return path;
+}
+
+const FIXTURES = {
+ /** Prints argv one per line, then reports what the askpass seam looked like. */
+ argvAndEnv: `#!/bin/sh
+for arg in "$@"; do
+ printf 'ARGV %s\\n' "$arg"
+done
+printf 'HAS_ASKPASS %s\\n' "\${SSH_ASKPASS:+set}"
+printf 'ASKPASS_REQUIRE %s\\n' "\${SSH_ASKPASS_REQUIRE:-unset}"
+printf 'SECRET_FILE %s\\n' "\${${ASKPASS_SECRET_ENV}:-unset}"
+printf 'HELPER_PATH %s\\n' "\${SSH_ASKPASS:-unset}"
+if [ -n "\${${ASKPASS_SECRET_ENV}}" ]; then
+ # POSIX find -perm rather than ls, whose permissions column differs per
+ printf 'SECRET_MODE %s\\n' "$(find "\${${ASKPASS_SECRET_ENV}}" -perm 600 -print)"
+ printf 'HELPER_MODE %s\\n' "$(find "\$SSH_ASKPASS" -perm 700 -print)"
+ printf 'DIR_MODE %s\\n' "$(find "$(dirname "\${${ASKPASS_SECRET_ENV}}")" -perm 700 -print)"
+ printf 'HELPER_READS %s\\n' "$(sh "\$SSH_ASKPASS")"
+ printf 'HELPER_RUNS %s\\n' "$("\$SSH_ASKPASS" "[email protected]'s password:")"
+fi
+`,
+};
+
+/** The askpass secret path a fixture child reported, for lifetime assertions. */
+function secretPathOf(stdout) {
+ return stdout
+ .split("\n")
+ .find((line) => line.startsWith("SECRET_FILE "))
+ ?.slice("SECRET_FILE ".length);
+}
+test("sshCommonArgs keeps a key-authenticated target on BatchMode", () => {
+ const args = sshCommonArgs({ host: "remote.example" });
+ const index = args.indexOf("BatchMode=yes");
+ assert.notEqual(index, -1, "the default path must still fail instead of prompting");
+ assert.equal(args.includes("BatchMode=no"), false);
+ assert.equal(args.includes("NumberOfPasswordPrompts=1"), false);
+ // No password means no askpass plumbing at all.
+ assert.equal(args.includes("-o"), true);
+ assert.equal(args.some((arg) => arg.includes("NumberOfPasswordPrompts")), false);
+});
+
+test("sshCommonArgs relaxes BatchMode only for a password target", () => {
+ const args = sshCommonArgs({ host: "remote.example", user: "deploy", password: PASSWORD });
+ assert.equal(args.includes("BatchMode=no"), true, "the prompt must be allowed");
+ assert.equal(args.includes("BatchMode=yes"), false);
+ // Exactly one answer can be given, so exactly one attempt may be made: a
+ // retry against a wrong password is what trips server-side lockouts.
+ const index = args.indexOf("NumberOfPasswordPrompts=1");
+ assert.notEqual(index, -1);
+ assert.equal(args[index - 1], "-o");
+ // The secret is nowhere in the argv, in any form.
+ for (const arg of args) {
+ assert.equal(arg.includes(PASSWORD), false, "the password must never be an ssh argument");
+ }
+ assert.equal(args.at(-1), "[email protected]");
+});
+
+test("a password target reaches ssh through the askpass helper and nowhere else", { timeout: TEST_TIMEOUT_MS }, async (t) => {
+ const binary = await writeFixture(t, FIXTURES.argvAndEnv, "ssh-askpass-probe");
+ const transport = createSystemSshTransport(
+ { host: "remote.example", user: "deploy", password: PASSWORD },
+ { binary },
+ );
+ t.after(() => transport.dispose());
+
+ const result = await transport.exec("id -u");
+ const lines = result.stdout.split("\n").filter(Boolean);
+ const read = (key) => lines.find((line) => line.startsWith(`${key} `))?.slice(key.length + 1);
+ const argv = lines.filter((line) => line.startsWith("ARGV ")).map((line) => line.slice(5));
+
+ // The secret is not an argument…
+ for (const arg of argv) {
+ assert.equal(arg.includes(PASSWORD), false, `argv leaked the password: ${arg}`);
+ }
+ assert.equal(argv.at(-1), "id -u");
+ assert.equal(argv.at(-2), "[email protected]");
+
+ // …but the helper is wired up and answers with it.
+ assert.equal(read("HAS_ASKPASS"), "set");
+ assert.equal(read("ASKPASS_REQUIRE"), "force");
+ assert.notEqual(read("SECRET_FILE"), "unset");
+ assert.equal(read("HELPER_READS"), PASSWORD, "the helper returns the secret whole");
+ assert.equal(read("HELPER_RUNS"), PASSWORD, "ssh's own prompt is answered by the helper");
+ // The helper is executable only by its owner, and the secret only readable by
+ // its owner. The modes are checked inside the child, because the material is
+ // already deleted by the time this assertion runs — which is itself the next
+ // thing asserted.
+ const secretPath = read("SECRET_FILE");
+ assert.notEqual(read("SECRET_MODE"), "", "the secret must be 0600");
+ assert.notEqual(read("HELPER_MODE"), "", "the helper must be 0700");
+ assert.notEqual(read("DIR_MODE"), "", "the credential directory must be 0700");
+
+ // The material is gone once the child that needed it is done.
+ await assert.rejects(stat(secretPath));
+});
+
+test("a key-authenticated transport is handed no askpass material", { timeout: TEST_TIMEOUT_MS }, async (t) => {
+ const binary = await writeFixture(t, FIXTURES.argvAndEnv, "ssh-no-askpass");
+ const transport = createSystemSshTransport({ host: "remote.example" }, { binary });
+ t.after(() => transport.dispose());
+
+ const result = await transport.exec("id -u");
+ const lines = result.stdout.split("\n").filter(Boolean);
+ const read = (key) => lines.find((line) => line.startsWith(`${key} `))?.slice(key.length + 1);
+
+ // The fixture prints an empty value for an unset variable, so "no askpass"
+ // looks like the empty string rather than a missing line.
+ assert.equal(read("HAS_ASKPASS"), "");
+ assert.equal(read("SECRET_FILE"), "unset");
+ assert.equal(read("HELPER_PATH"), "unset");
+ // Nothing was written, so nothing had to be cleaned up.
+ assert.equal(read("HELPER_READS"), undefined);
+});
+
+test("each command gets its own credential, and none outlives it", { timeout: TEST_TIMEOUT_MS }, async (t) => {
+ const binary = await writeFixture(t, FIXTURES.argvAndEnv, "ssh-per-command-secret");
+ const transport = createSystemSshTransport(
+ { host: "remote.example", password: PASSWORD },
+ { binary },
+ );
+ t.after(() => transport.dispose());
+
+ const first = await transport.exec("uname -s");
+ const firstSecret = secretPathOf(first.stdout);
+ // The first command is finished, so its copy is already gone — the secret is
+ // on disk only while a child can still be prompting for it.
+ await assert.rejects(stat(firstSecret));
+
+ const second = await transport.exec("id -u");
+ const secondSecret = secretPathOf(second.stdout);
+ assert.notEqual(firstSecret, secondSecret, "a new credential is minted per command");
+ await assert.rejects(stat(secondSecret));
+});
+
+test("dispose removes credential material that no child has reclaimed", { timeout: TEST_TIMEOUT_MS }, async (t) => {
+ const binary = await writeFixture(t, FIXTURES.argvAndEnv, "ssh-dispose-secret");
+ const transport = createSystemSshTransport(
+ { host: "remote.example", password: PASSWORD },
+ { binary },
+ );
+ await transport.exec("id -u");
+ // `dispose` has to be safe to call after the normal release, and it must not
+ // leave a stray directory behind for the next launch to find.
+ transport.dispose();
+ transport.dispose();
+});
+
+test("the helper script is POSIX shell that reads the secret by path", async () => {
+ assert.ok(ASKPASS_HELPER_SCRIPT.startsWith("#!/bin/sh"));
+ assert.ok(ASKPASS_HELPER_SCRIPT.includes(`\${${ASKPASS_SECRET_ENV}}`));
+ // A literal secret could only have got here by being interpolated; the only
+ // thing the script may contain is the indirection through the environment.
+ assert.ok(ASKPASS_HELPER_SCRIPT.endsWith("echo\n"));
+});
+
+test("assertSshPassword refuses what OpenSSH could never receive", () => {
+ assert.equal(assertSshPassword(PASSWORD), PASSWORD);
+ // A leading or trailing space is a valid password and must survive.
+ assert.equal(assertSshPassword(" spaced "), " spaced ");
+ // OpenSSH reads the helper's answer up to the first line break, so a secret
+ // containing one would be silently truncated into a different password.
+ assert.throws(() => assertSshPassword("two\nlines"), /line break/);
+ assert.throws(() => assertSshPassword("two\rlines"), /line break/);
+ assert.throws(() => assertSshPassword(""), /must not be empty/);
+ assert.throws(() => assertSshPassword(null), /must be a string/);
+ assert.throws(() => assertSshPassword("x".repeat(4097)), /at most/);
+});
+
+test("createSshAskpass refuses Windows instead of writing a helper that cannot run", async (t) => {
+ const dir = await tmpDir(t);
+ await assert.rejects(
+ createSshAskpass(PASSWORD, { dir, platform: "win32" }),
+ (error) => error.errorCode === "HOST_BOOTSTRAP_FAILED" && /Windows/.test(error.message),
+ );
+ // Nothing may have been created on the way to that refusal.
+ const { readdir } = await import("node:fs/promises");
+ assert.deepEqual(await readdir(dir), []);
+});
+
+test("createSshAskpass writes a 0600 secret in a 0700 directory and cleans up", async (t) => {
+ const parent = await tmpDir(t);
+ const material = await createSshAskpass(PASSWORD, { dir: parent });
+ const secretPath = material.env[ASKPASS_SECRET_ENV];
+ const helperPath = material.env.SSH_ASKPASS;
+ const root = dirname(secretPath);
+
+ assert.equal(material.env.SSH_ASKPASS_REQUIRE, "force");
+ assert.equal(await readFile(secretPath, "utf8"), PASSWORD);
+ assert.equal((await stat(secretPath)).mode & 0o777, 0o600);
+ assert.equal((await stat(helperPath)).mode & 0o777, 0o700);
+ assert.equal((await stat(root)).mode & 0o777, 0o700);
+
+ await material.dispose();
+ await assert.rejects(stat(root));
+ // Idempotent: a second close must not throw over the already-deleted files.
+ await material.dispose();
+});
+
+test("the persisted record carries the password encrypted and reads it back", async (t) => {
+ const dir = await tmpDir(t);
+ const encryption = fakeEncryption();
+ const registry = createRemoteHostRegistry({ dataDir: dir, encryption });
+ const record = sshHostRecord({
+ hostKey: "ssh-remote.example-prod",
+ label: "Prod box",
+ url: "ws://127.0.0.1:41234/v1/racp/ws",
+ deviceToken: "dt_secret",
+ ssh: { host: "remote.example", user: "deploy", auth: "password", remotePort: 41234, version: "1.2.3" },
+ sshSecret: PASSWORD,
+ });
+ await registry.upsert(record);
+
+ const raw = await readFile(join(dir, "remote-hosts.json"), "utf8");
+ assert.equal(raw.includes(PASSWORD), false, "the password must not be on disk in clear text");
+ assert.ok(raw.includes("encryptedSshSecret"));
+
+ const [stored] = await registry.list();
+ assert.equal(stored.sshSecret, PASSWORD);
+ assert.equal(stored.deviceToken, "dt_secret");
+ assert.equal(sshMetadataOf(stored)?.auth, "password");
+ assert.equal(transportOf(stored), "ssh");
+ // The secret is in the record, never in the descriptor the renderer receives.
+ assert.equal(JSON.stringify(sshMetadataOf(stored)).includes(PASSWORD), false);
+});
+
+test("a record written before password auth reads back unchanged", async (t) => {
+ const dir = await tmpDir(t);
+ const encryption = fakeEncryption();
+ const registry = createRemoteHostRegistry({ dataDir: dir, encryption });
+ await registry.upsert(
+ sshHostRecord({
+ hostKey: "legacy",
+ label: "Legacy",
+ url: "ws://127.0.0.1:1/v1/racp/ws",
+ deviceToken: "dt",
+ // No password, so no `auth` field: exactly the pre-password-auth shape.
+ ssh: { host: "old.example", remotePort: 22, version: "1.2.3" },
+ }),
+ );
+
+ const [stored] = await registry.list();
+ assert.equal(stored.sshSecret, undefined);
+ const metadata = sshMetadataOf(stored);
+ assert.equal(metadata?.auth, undefined, "a key descriptor must not gain an auth field");
+ assert.deepEqual(metadata, { host: "old.example", remotePort: 22, version: "1.2.3" });
+ const raw = await readFile(join(dir, "remote-hosts.json"), "utf8");
+ assert.equal(raw.includes("encryptedSshSecret"), false);
+});
+
+test("an undecryptable password costs the secret, not the paired host", async (t) => {
+ const dir = await tmpDir(t);
+ await createRemoteHostRegistry({ dataDir: dir, encryption: fakeEncryption() }).upsert(
+ sshHostRecord({
+ hostKey: "h",
+ label: "H",
+ url: "u",
+ deviceToken: "dt_keep_me",
+ ssh: { host: "remote.example", auth: "password", remotePort: 1, version: "1" },
+ sshSecret: PASSWORD,
+ }),
+ );
+
+ // Simulate a keychain that moved: the device token still decrypts, the SSH
+ // password does not. Dropping the whole record would hide a paired host.
+ const encryption = fakeEncryption();
+ const original = encryption.decryptString.bind(encryption);
+ encryption.decryptString = (buffer) => {
+ if (buffer.toString("utf8").includes(PASSWORD)) throw new Error("cannot decrypt");
+ return original(buffer);
+ };
+ const [stored] = await createRemoteHostRegistry({ dataDir: dir, encryption }).list();
+ assert.equal(stored.deviceToken, "dt_keep_me");
+ assert.equal(stored.sshSecret, undefined);
+});
+
+test("sshTargetOf carries the secret beside the descriptor, never inside it", () => {
+ const ssh = { host: "remote.example", user: "deploy", auth: "password", remotePort: 1, version: "1" };
+ const withSecret = sshTargetOf(ssh, PASSWORD);
+ assert.equal(withSecret.password, PASSWORD);
+ assert.equal(JSON.stringify(ssh).includes(PASSWORD), false, "the descriptor stays secret-free");
+
+ // Absent secret means key auth, which is the pre-existing behaviour.
+ assert.equal("password" in sshTargetOf(ssh), false);
+});
diff --git a/docs/adr/0293-ssh-password-authentication.md b/docs/adr/0293-ssh-password-authentication.md
new file mode 100644
index 000000000..6028fc203
--- /dev/null
+++ b/docs/adr/0293-ssh-password-authentication.md
@@ -0,0 +1,182 @@
+# ADR 0293: SSH password authentication for the remote-host bootstrap
+
+- Status: Accepted
+- Date: 2026-09-19
+- Decision: D454
+- Amends: [ADR 0292](0292-ssh-remote-host-bootstrap.md) — its "no SSH secret is
+- Related: [ADR 0286](0286-remote-host-desktop-kernel.md) (D449), ADR 0205 (D373),
+ `02-architecture/05-remote-agent-control.md` §5.2,
+ `05-security/02-remote-control-security.md` §3.4
+
+## Context
+
+ADR 0292 bootstraps a `pi-host` on a machine the user already reaches over SSH
+by shelling out to the system `ssh` client. That choice was made deliberately
+and its main argument was that the app holds no SSH secret at all:
+`~/.ssh/config`, the agent, and `known_hosts` decide the login, so there is
+nothing for the app to leak. `BatchMode=yes` enforced the claim — a host that
+needed an interactive password failed immediately with a typed error instead of
+hanging behind an invisible prompt.
+
+That is the right default and it stays. It is not, however, sufficient for the
+machines this feature exists for. A fresh cloud instance, a NAS, a container
+host, or any box provisioned with a password and no key yet is reachable from a
+terminal after one `ssh` prompt, while the desktop refuses it. The user's only
+recourse is to install a key from a terminal first — which is exactly the
+"use your terminal instead" detour the bootstrap was built to remove.
+
+There is no way to support that case while keeping the invariant literally
+true. Accepting a password means the app holds a secret, so the decision is
+what shape that takes, not whether it exists. Three constraints bound the
+answer:
+
+- The transport spawns `ssh` with no terminal, so a password cannot simply be
+ handed over; OpenSSH must be given a way to ask for one.
+- A secret that must survive a restart to keep reconnecting is a secret at rest,
+ and the app already has exactly one encrypted-at-rest store it trusts.
+- The transport is a port (`SshTransport`) with the bootstrap and the tunnel
+ manager on the other side of it, so whatever carries the secret has to be
+ expressible through that seam.
+
+## Decision
+
+1. **Password auth is opt-in, and a key or agent stays the default.** Absent
+ credentials, the argv is byte-for-byte what ADR 0292 produced, `BatchMode=yes`
+ included. A target that carries a password is the only one that differs.
+
+2. **The secret reaches `ssh` through OpenSSH's own askpass helper**
+ (`remote/ssh-askpass.ts`). `SSH_ASKPASS` names a generated `/bin/sh` script
+ and `SSH_ASKPASS_REQUIRE=force` makes `ssh` use it without a terminal; the
+ script `cat`s the secret from a file and terminates the line, because
+ `ssh` reads the helper's answer only up to the first line break. The secret
+ is therefore never an `ssh` argument and never an environment variable — it
+ is a path in the environment and bytes in a file, so `ps` output and argv
+ dumps stay clean. Its confidentiality rests on modes rather than convention:
+ a `0700` directory created by `mkdtemp`, a `0600` secret, a `0700` helper.
+
+3. **`BatchMode=yes` becomes `BatchMode=no` only when a password is supplied,
+ together with `NumberOfPasswordPrompts=1`.** The helper answers every prompt
+ with the same secret, so a retry could only repeat a wrong password, and
+ repeated failures are what trip a server's own lockout. One prompt, one
+ answer. An encrypted key whose passphrase is not that password falls through
+ to password authentication, which is the behaviour a user with both expects.
+
+4. **The credential is short-lived.** Material is written when a child is about
+ to authenticate and deleted once it cannot still be prompting: after an
+ `exec` / `execWithInput` child has closed, after a forward's local port is
+ up, or on `dispose`. A reference count keeps a shared copy alive across
+ concurrent children and drops it when the last one is done, so the ordinary
+ case leaves one file on disk for the duration of one authentication and
+ nothing afterwards.
+
+5. **The password is persisted encrypted, in a new record field.**
+ `RemoteHostRecord.sshSecret` is written to `remote-hosts.json` as
+ `encryptedSshSecret` through the same `safeStorage`-backed `EncryptionPort`
+ the device token already uses, and read back the same way. The descriptor in
+ `metadata.ssh` gains `auth: "password"` — and only that value is written, so
+ a key descriptor and every record written before this change keep exactly the
+ shape they had. A record whose SSH password will not decrypt (keychain moved,
+ different OS user) loses the secret but keeps the paired host, because the
+ device token is independent of it.
+
+6. **The secret never reaches the renderer.** `RemoteHostSshMetadata` stays
+ secret-free by construction: it is plaintext metadata, it is stored in
+ `metadata`, and it is echoed to the renderer inside
+ `RemoteHostBootstrapResult`. The password travels beside it — from the IPC
+ request into `SshTarget.password`, and back out of the bootstrap as
+ `SshBootstrapOutcome.sshSecret` for the caller to encrypt — and
+ `RemoteHostSummary` is unchanged.
+
+7. **A password that cannot work is refused before anything runs.** A line break
+ cannot survive the askpass round trip, so `assertSshPassword` rejects one with
+ `INVALID_ARGUMENT` in the bootstrap rather than letting it become a failed
+ authentication. Windows is refused with `HOST_BOOTSTRAP_FAILED` naming the
+ remedy, because Windows OpenSSH cannot execute a shell-script askpass helper
+ and shipping a helper executable is a project of its own. A host recorded as
+ `auth: "password"` with no usable secret is not opened at all, which is
+ reported as the host being disconnected instead of as a rejected login.
+
+8. **The Settings surface says what it does.** The SSH form gains an
+ authentication mode with a masked password field and a reveal toggle, and its
+ description states that the login password is saved in the OS keychain so the
+ host reconnects after a restart. The copy that promised no password was ever
+ stored is replaced in all eight shipped locales.
+
+## Invariants
+
+- With no password supplied, nothing changes: same argv, same
+ `BatchMode=yes`, no credential file created, no askpass variables set.
+- The password is never an `ssh` argument, never an environment variable value,
+ never in a URL, never in a log line, and never in a renderer payload.
+- Credential files exist only inside a `0700` directory, only for the interval
+ in which an `ssh` child can still prompt, and are removed on every path —
+ including `dispose` and a failed `forward`.
+- Nothing but the system `ssh` client consumes the secret; no library,
+ no second credential store, and no keychain entry of its own.
+- A malformed or absent descriptor still degrades to "not an SSH host" rather
+ than to a spawn with junk arguments.
+
+## Out of scope
+
+- **Interactive (non-persisted) prompting.** The password is supplied once by
+ the user in Settings and either remembered encrypted or not at all; there is
+ no "ask me each time" mode, which would need a main-process prompt surface.
+- **Keyboard-interactive auth as a separate mode.** `ssh` treats it as the same
+ prompt, so the helper answers both with one secret and there is no second
+ switch to expose.
+- **Windows support**, as above, and **non-Linux remote targets**, unchanged
+ from ADR 0292.
+- **Key passphrase storage.** A passphrase unlocks a local key; the askpass
+ helper answers that prompt only as a side effect of the same secret being
+ supplied for the login.
+
+## Alternatives considered
+
+- **`sshpass`, or `SSH_ASKPASS` with the secret in the environment.**
+ Rejected: `sshpass` is a third-party dependency that must be installed, and
+ either form exposes the secret to anything that can read the process
+ environment or arguments — including other users on a shared machine.
+- **A PTY and a scripted `expect`-style dialog.** Rejected: it reintroduces a
+ pseudo-terminal whose prompts and timing the desktop would have to parse, and
+ it makes an interactive prompt possible again on a path that was designed to
+ fail closed.
+- **Store the password unencrypted in `metadata`.** Rejected: `metadata` is
+ plaintext, is user-editable, and is not covered by the keychain, so it would
+ put a reusable credential into a file the app cannot protect.
+- **Keep nothing at rest and ask on every launch.** Rejected for now: it would
+ make an SSH host the only paired host that needs a human at startup, so a
+ restart would silently leave it offline. Encrypting it in the same store as
+ the device token keeps one credential model instead of two.
+- **`ssh -o PreferredAuthentications=password`.** Rejected: forcing the method
+ breaks the fall-through a user with both a key and a password relies on, and
+ it turns a working agent login into a failure.
+
+## Testing
+
+`apps/desktop/test/remote-host-ssh-password.test.mjs` drives the whole path with
+fixture executables and a fake `EncryptionPort`, so nothing touches a network or
+a real keychain. It asserts the argv of a password spawn carries no secret and
+the argv of a key spawn is unchanged, that the helper answers exactly what the
+secret file holds, that the file, the helper, and their directory carry
+`0600` / `0700` / `0700`, that material is gone once its child is done and after
+`dispose`, that a round trip through the registry leaves no cleartext in
+`remote-hosts.json`, and that a pre-existing key record reads back with no added
+field.
+
+## Consequences
+
+- The desktop can now be asked to hold an SSH password, which is a real widening
+ of what the app is trusted with. It is bounded by being opt-in per host,
+ encrypted at rest through the store that already exists, and never exposed to
+ the renderer or the process table.
+- `remote-hosts.json` gains an optional `encryptedSshSecret` and
+ `metadata.ssh.auth`. Both are additive: the file's `version` stays `1`, and a
+ key-authenticated record is written exactly as before.
+- Users can now bootstrap a host whose only credential is a password, which
+ removes the terminal detour that ADR 0292's `BatchMode=yes` left in place.
+- Server-side lockout policy becomes reachable through the app: one wrong saved
+ password produces one failed attempt per connect. `NumberOfPasswordPrompts=1`
+ keeps that to the minimum the user asked for.
+- The `settings.remoteHosts` copy that claimed no password is ever stored had to
+ change in eight locales, and the claim in ADR 0292 needed an explicit
+ amendment rather than a quiet edit.
diff --git a/docs/adr/README.md b/docs/adr/README.md
index 8081875b6..e037741a5 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -319,4 +319,5 @@ Each ADR includes:
| 0290 | [Restore resizable sidebar width with collapse-below-threshold](0290-resizable-sidebar-collapse-threshold.md) | Accepted (D451; amends ADR 0141 / ADR 0238) |
| 0291 | [Remove the speech settings UI](0291-remove-speech-settings-ui.md) | Accepted (amends ADR 0281) |
| 0292 | [SSH bootstrap for remote hosts](0292-ssh-remote-host-bootstrap.md) | Accepted for implementation (D453; ADR 0205 R2b, extends ADR 0286) |
+| 0293 | [SSH password authentication for the remote-host bootstrap](0293-ssh-password-authentication.md) | Accepted (D454; amends ADR 0292) |
| turn-process-and-thinking-display | [Turn process and thinking presentation](turn-process-and-thinking-display.md) | Accepted |
diff --git a/docs/spec/02-architecture/05-remote-agent-control.md b/docs/spec/02-architecture/05-remote-agent-control.md
index a2c23f7a8..49fa83d94 100644
--- a/docs/spec/02-architecture/05-remote-agent-control.md
+++ b/docs/spec/02-architecture/05-remote-agent-control.md
@@ -154,7 +154,11 @@ PI-Desktop (Remote Client) Remote machine
Bootstrap runs over the user's own SSH session, never over RACP:
-1. The desktop opens SSH with the user's existing configuration and keys.
+1. The desktop opens SSH with the user's existing configuration and keys. A
+ login password MAY be supplied instead of a key (ADR 0293): it is handed to
+ the `ssh` client through an askpass helper, never as an argument, and is
+ stored encrypted in the desktop's secure storage so the host can reconnect
+ after a restart.
2. It uploads a small bootstrap script that downloads the `pi-host` bundle
for the remote platform at the desktop's version from GitHub Releases,
verifies the published SHA-256, and installs it under the user's home. A
diff --git a/docs/spec/05-security/02-remote-control-security.md b/docs/spec/05-security/02-remote-control-security.md
index e5dac874e..d3c627a1c 100644
--- a/docs/spec/05-security/02-remote-control-security.md
+++ b/docs/spec/05-security/02-remote-control-security.md
@@ -159,6 +159,24 @@ pairing only binds a desktop device to the Host it started.
- Provider configuration for the remote Host is written over the SSH channel
by the bootstrap step as Host-local configuration; it never crosses RACP.
+**SSH credential handling (ADR 0293).** The desktop MAY hold the SSH login
+password for a host the user paired that way, under these rules:
+
+- The password is supplied by the user in Settings, is passed to the system
+ `ssh` client through OpenSSH's askpass helper, and is never an `ssh`
+ argument, an environment variable value, or part of a URL.
+- Credential material exists on disk only inside a `0700` directory as a `0600`
+ file, only while an `ssh` child can still prompt for it, and is removed on
+ every path including a failed forward and `dispose`.
+- It is persisted at rest only through the same OS-keychain encryption the
+ device token uses, and a password that cannot be decrypted costs the secret
+ rather than the paired host.
+- The renderer never receives it: `RemoteHostSummary` and
+ `RemoteHostSshMetadata` carry no secret field.
+- A password containing a line break cannot survive the askpass round trip and
+ is rejected before any remote command runs. Windows OpenSSH cannot execute
+ the helper and is refused with a remedy instead.
+
## 4. Authorization model
### 4.1 Role matrix
@@ -478,7 +496,10 @@ separate, explicitly specified credential-management capability is added.
20. A session terminal opens only for the SSH-paired owner or a principal
with the `terminal` scope, with its working directory inside the session
root.
-
+ root.
+21. An SSH login password is supplied only by the user, reaches `ssh` only
+ through the askpass helper, is stored only encrypted, and never appears in
+ a process argument list, the renderer, or a log line.
## 13. Amendment history
D374 (2026-09-10) added the browser cookie/header authentication profiles,
@@ -502,3 +523,8 @@ D385 (2026-09-10) withdrew the first-party identity source: remote control
is user-local by construction, every credential is issued by the user's own
Host, and any Gateway is self-hosted and admits clients with those device
credentials.
+
+D454 (2026-09-19) added SSH password authentication for the bootstrap (§3.4,
+ADR 0293): the credential-handling rules above and gate 21. It relaxes
+`BatchMode=yes` for a password target only, with `NumberOfPasswordPrompts=1`,
+and keeps a key or agent as the default path.
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index e231baa44..13a0b7159 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -11830,6 +11830,47 @@ browser milestones are scheduled.
- **Milestone**: Post-MVP (rollout R2)
- **Status**: Draft; remote harness with a Linux SSH target required
+#### E2E-REMOTE-HOST-ssh-password-authentication
+
+- **Preconditions**: A Linux test machine runs `sshd` with
+ `PasswordAuthentication yes` and `PubkeyAuthentication no`, so the login is
+ only reachable with a password; the user's local SSH agent holds no usable key
+ for it. A GitHub Releases fixture serves the `pi-host` bundle for that platform
+ at the desktop's version. A second machine accepts the user's key only.
+- **Steps**: 1) In Settings → Remote Hosts, install over SSH with key
+ authentication and confirm the form shows the identity-file field.
+ 2) Switch the authentication mode to password, confirm the identity-file field
+ is replaced by a masked password field, and reveal it once.
+ 3) Try to submit an empty password. 4) Point the form at the
+ password-only machine, enter the password, and bootstrap it.
+ 5) Quit the desktop, relaunch it, and let the host reconnect.
+ 6) Change the saved password to a wrong value through a re-pair, then force a
+ reconnect. 7) Bootstrap the key-only machine with a password supplied.
+ 8) Inspect the desktop's process arguments and `remote-hosts.json` while a
+ password-authenticated host is connected. 9) Attempt to submit a password
+ containing a newline through the IPC channel directly.
+- **Expected**: Key mode is byte-for-byte today's behaviour — `BatchMode=yes` and
+ no credential file anywhere. In password mode the password field replaces the
+ identity-file field, the reveal toggle shows and re-hides the value, and an
+ empty password keeps the submit disabled. The password-only machine installs
+ and pairs. After the relaunch the host reconnects with no prompt, proving the
+ saved credential is used. The wrong password yields exactly one failed attempt
+ per connect (no helper-driven retry storm) and the host shows as offline rather
+ than crashing the app or showing a rejected-login dialog. The key-only machine
+ still authenticates with the key. No `ssh` argument contains the password, no
+ askpass file or directory remains after the connect completes, and the on-disk
+ record stores the password only as keychain ciphertext — never in cleartext.
+ A password containing a newline is refused with `INVALID_ARGUMENT` before any
+ remote command runs.
+- **Specs linked**: `05-security/02-remote-control-security.md` §§3.4 and 13
+ (gate 21), `02-architecture/05-remote-agent-control.md` §5.2,
+ `06-delivery/07-remote-control-rollout.md` §2
+- **Acceptance**: Security, D (surfaces), Quality
+- **Milestone**: Post-MVP (rollout R2b)
+- **Status**: Draft; remote harness with a password-only Linux SSH target
+ required. The credential seam itself is covered offline by
+ `apps/desktop/test/remote-host-ssh-password.test.mjs`.
+
#### E2E-232: The outbound messaging integration relays events and commands
- **Preconditions**: A Host runs with the integration adapter configured
diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.md
index 9f107ee49..15ac16907 100644
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@ -6153,3 +6153,45 @@ that was sitting at the bottom — including after the turn had finished.
still fails `turn/start` closed with `MODEL_NOT_CONFIGURED` until a provider is
configured on it. See ADR 0292, `06-delivery/07-remote-control-rollout.md` §7,
and `05-security/02-remote-control-security.md` §3.4.
+
+## 2026-09-19 — SSH password authentication for the bootstrap (D454)
+
+- ADR 0292 kept the app free of SSH secrets and made `BatchMode=yes` the
+ enforcer, which is the right default but leaves a machine whose only
+ credential is a password unreachable from the app — the user has to install a
+ key from a terminal first, which is the detour the bootstrap exists to
+ remove. A password may now be supplied *instead of* a key, per host, and it
+ is opt-in: with no password the argv and every other behaviour are unchanged.
+- The secret reaches the `ssh` client through OpenSSH's askpass helper
+ (`remote/ssh-askpass.ts`): `SSH_ASKPASS` points at a generated `/bin/sh`
+ script and `SSH_ASKPASS_REQUIRE=force` makes it apply without a terminal, so
+ the password is never an `ssh` argument or an environment value. Its
+ confidentiality rests on modes — a `0700` directory, a `0600` secret, a `0700`
+ helper — and the material is deleted once no child can still be prompting
+ (after an exec child closes, after a forward's port is up, or on `dispose`),
+ so nothing lingers between operations.
+- `BatchMode=yes` becomes `BatchMode=no` only for a password target, together
+ with `NumberOfPasswordPrompts=1`: the helper answers every prompt with the
+ same secret, so a retry could only repeat a wrong password, and repeated
+ failures are what trip a server's own lockout.
+- The password is persisted encrypted through the same OS-keychain
+ `EncryptionPort` the device token uses, as a new optional
+ `encryptedSshSecret` in `remote-hosts.json`; the descriptor gains
+ `auth: "password"` and nothing else, so a key descriptor keeps exactly its
+ previous shape and the file's `version` stays `1`. A password that will not
+ decrypt costs the secret, not the paired host, because the device token is
+ independent of it.
+- The renderer never sees it: `RemoteHostSummary` is unchanged and the secret
+ travels beside `RemoteHostSshMetadata` (plaintext, persisted metadata) rather
+ than inside it. `assertSshPassword` rejects a line break with
+ `INVALID_ARGUMENT` before any remote command runs, because OpenSSH reads the
+ helper's answer only up to the first break; Windows is refused with
+ `HOST_BOOTSTRAP_FAILED` and a remedy, because its OpenSSH cannot execute a
+ shell-script helper. A host recorded as password-authenticated with no usable
+ secret is not opened at all, which surfaces as the host being offline.
+- Settings gains an authentication mode on the SSH form with a masked password
+ field and a reveal toggle, and the copy that promised no password was ever
+ stored is replaced in all eight shipped locales. See ADR 0293,
+ `05-security/02-remote-control-security.md` §3.4 and gate 21,
+ `02-architecture/05-remote-agent-control.md` §5.2,
+ E2E-REMOTE-HOST-ssh-password-authentication.
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index 8532259e7..3f1927625 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -819,6 +819,7 @@ sklm: {
"removed": "{{label}} entfernt.",
"removeFailed": "Entfernen fehlgeschlagen: {{message}}",
"pairTitle": "Neuen Host koppeln",
+ "pairBody": "Für einen pi-host, den Sie selbst betreiben: RACP-URL und den Kopplungstoken aus seiner Startausgabe einfügen.",
"pair": "Koppeln",
"pairing": "Koppelt…",
"pairAction": "Hinzufügen",
@@ -832,7 +833,7 @@ sklm: {
"fieldPairingToken": "Kopplungstoken",
"fieldPairingTokenDesc": "Einmaliger ppt1.*-Token aus der pi-host-Bootstrap-Ausgabe. Wird beim Koppeln verbraucht.",
"sshTitle": "Installation auf einem Server (SSH)",
- "sshBody": "PI-Desktop installiert pi-host auf einem Rechner, den Sie bereits per ssh erreichen, prüft die vom Release veröffentlichte Prüfsumme, startet ihn auf Loopback und koppelt sich damit. Ihre eigenen SSH-Schlüssel authentifizieren — es wird kein Passwort gespeichert.",
+ "sshBody": "PI-Desktop installiert pi-host auf einem Rechner, den Sie bereits per ssh erreichen, und hält einen Loopback-Tunnel dorthin. Ihre eigene ssh-Konfiguration und Ihr Agent gelten; statt eines Schlüssels kann auch ein Anmeldepasswort verwendet werden.",
"sshHost": "SSH-Host",
"sshHostDesc": "Hostname oder Adresse, genau so, wie ssh sie erhält.",
"sshHostPlaceholder": "build-box.local",
@@ -842,7 +843,18 @@ sklm: {
"sshPortDesc": "Leer lassen für den ssh-Standard (22).",
"sshIdentityFile": "Identitätsdatei",
"sshIdentityFileDesc": "Pfad zum privaten Schlüssel; leer lassen, damit der Agent und ~/.ssh/config entscheiden.",
+ "sshAuthMode": "Authentifizierung",
+ "sshAuthModeDesc": "Verwenden Sie Ihren eigenen SSH-Schlüssel oder Agent — oder authentifizieren Sie sich mit einem Passwort.",
+ "sshAuthKey": "SSH-Schlüssel",
+ "sshAuthPassword": "Passwort",
+ "sshPassword": "Passwort",
+ "sshPasswordDesc": "Wird dem ssh-Client über einen askpass-Helfer übergeben, nie auf der Kommandozeile.",
+ "sshPasswordPlaceholder": "Ihr Anmeldepasswort",
+ "sshShowPassword": "Passwort anzeigen",
+ "sshHidePassword": "Passwort verbergen",
+ "sshPasswordStored": "Im Schlüsselbund des Betriebssystems gespeichert, damit sich dieser Host nach einem Neustart wieder verbindet.",
"sshAction": "Installieren und koppeln",
+ "sshActionHint": "Installiert pi-host auf dem Host und koppelt ihn mit diesem Desktop.",
"sshRunning": "Wird installiert…",
"sshSucceeded": "{{label}} installiert und gekoppelt.",
"sshFailed": "Installation fehlgeschlagen: {{message}}",
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index effe4ac8a..6ee0344c0 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -827,6 +827,7 @@ sklm: {
removed: "{{label}} removed.",
removeFailed: "Failed to remove: {{message}}",
pairTitle: "Pair a new host",
+ pairBody: "For a pi-host you already run yourself: paste its RACP URL and the pairing token from its startup output.",
pair: "Pair",
pairing: "Pairing…",
pairAction: "Add",
@@ -843,7 +844,7 @@ sklm: {
"Single-use ppt1.* token from the pi-host bootstrap output. Consumed on pair.",
sshTitle: "Install on a server (SSH)",
sshBody:
- "PI-Desktop installs pi-host on a machine you already reach with ssh, verifies the checksum the release publishes, starts it on loopback, and pairs with it. Your own SSH keys authenticate — no password is stored.",
+ "PI-Desktop installs pi-host on a machine you already reach with ssh and keeps a loopback tunnel to it. Your own ssh configuration and agent apply; a login password can be used instead of a key.",
sshHost: "SSH host",
sshHostDesc: "Host name or address, exactly as ssh receives it.",
sshHostPlaceholder: "build-box.local",
@@ -854,7 +855,18 @@ sklm: {
sshIdentityFile: "Identity file",
sshIdentityFileDesc:
"Private key path; leave empty to let the agent and ~/.ssh/config decide.",
+ sshAuthMode: "Authentication",
+ sshAuthModeDesc: "Use your own SSH key or agent, or authenticate with a password.",
+ sshAuthKey: "SSH key",
+ sshAuthPassword: "Password",
+ sshPassword: "Password",
+ sshPasswordDesc: "Sent to the ssh client through an askpass helper, never on the command line.",
+ sshPasswordPlaceholder: "Your login password",
+ sshShowPassword: "Show password",
+ sshHidePassword: "Hide password",
+ sshPasswordStored: "Saved in the OS keychain so this host reconnects after a restart.",
sshAction: "Install and pair",
+ sshActionHint: "Installs pi-host on the host and pairs it with this desktop.",
sshRunning: "Installing…",
sshSucceeded: "{{label}} installed and paired.",
sshFailed: "Install failed: {{message}}",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index 5f598d467..494a237bf 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -819,6 +819,7 @@ sklm: {
"removed": "{{label}} eliminado.",
"removeFailed": "Error al eliminar: {{message}}",
"pairTitle": "Emparejar un nuevo host",
+ "pairBody": "Para un pi-host que ya ejecuta usted mismo: pegue su URL de RACP y el token de emparejamiento de su salida de inicio.",
"pair": "Emparejar",
"pairing": "Emparejando…",
"pairAction": "Añadir",
@@ -832,7 +833,7 @@ sklm: {
"fieldPairingToken": "Token de emparejamiento",
"fieldPairingTokenDesc": "Token ppt1.* de un solo uso del inicio de pi-host. Se consume al emparejar.",
"sshTitle": "Instalar en un servidor (SSH)",
- "sshBody": "PI-Desktop instala pi-host en una máquina a la que ya accede por ssh, verifica la suma de comprobación que publica la versión, lo inicia en bucle de retorno y se empareja con él. Sus propias claves SSH autentican; no se almacena ninguna contraseña.",
+ "sshBody": "PI-Desktop instala pi-host en una máquina a la que ya accede por ssh y mantiene un túnel de bucle de retorno hacia ella. Se aplican su propia configuración de ssh y su agente; también puede usar una contraseña de inicio de sesión en lugar de una clave.",
"sshHost": "Host SSH",
"sshHostDesc": "Nombre de host o dirección, exactamente como lo recibe ssh.",
"sshHostPlaceholder": "build-box.local",
@@ -842,7 +843,18 @@ sklm: {
"sshPortDesc": "Déjelo vacío para el valor predeterminado de ssh (22).",
"sshIdentityFile": "Archivo de identidad",
"sshIdentityFileDesc": "Ruta de la clave privada; déjela vacía para que lo decidan el agente y ~/.ssh/config.",
+ "sshAuthMode": "Autenticación",
+ "sshAuthModeDesc": "Use su propia clave SSH o agente, o autentíquese con una contraseña.",
+ "sshAuthKey": "Clave SSH",
+ "sshAuthPassword": "Contraseña",
+ "sshPassword": "Contraseña",
+ "sshPasswordDesc": "Se entrega al cliente ssh mediante un ayudante askpass, nunca en la línea de comandos.",
+ "sshPasswordPlaceholder": "Su contraseña de inicio de sesión",
+ "sshShowPassword": "Mostrar contraseña",
+ "sshHidePassword": "Ocultar contraseña",
+ "sshPasswordStored": "Se guarda en el llavero del sistema para que este host se reconecte tras un reinicio.",
"sshAction": "Instalar y emparejar",
+ "sshActionHint": "Instala pi-host en el host y lo empareja con este escritorio.",
"sshRunning": "Instalando…",
"sshSucceeded": "{{label}} instalado y emparejado.",
"sshFailed": "Error de instalación: {{message}}",
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index eab8153a3..5a4505e66 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -819,6 +819,7 @@ sklm: {
"removed": "{{label}} supprimé.",
"removeFailed": "Échec de la suppression : {{message}}",
"pairTitle": "Apparier un nouvel hôte",
+ "pairBody": "Pour un pi-host que vous exécutez vous-même : collez son URL RACP et le jeton d'appariement de sa sortie de démarrage.",
"pair": "Apparier",
"pairing": "Appariement…",
"pairAction": "Ajouter",
@@ -832,7 +833,7 @@ sklm: {
"fieldPairingToken": "Jeton d'appariement",
"fieldPairingTokenDesc": "Jeton ppt1.* à usage unique de la sortie de démarrage de pi-host. Consommé à l'appariement.",
"sshTitle": "Installation sur un serveur (SSH)",
- "sshBody": "PI-Desktop installe pi-host sur une machine à laquelle vous accédez déjà par ssh, vérifie la somme de contrôle publiée par la version, le démarre sur la boucle locale et s'y apparie. Vos propres clés SSH authentifient — aucun mot de passe n'est stocké.",
+ "sshBody": "PI-Desktop installe pi-host sur une machine à laquelle vous accédez déjà par ssh et maintient un tunnel en boucle locale vers elle. Votre propre configuration ssh et votre agent s'appliquent ; un mot de passe de connexion peut remplacer une clé.",
"sshHost": "Hôte SSH",
"sshHostDesc": "Nom d'hôte ou adresse, exactement tel que ssh le reçoit.",
"sshHostPlaceholder": "build-box.local",
@@ -842,7 +843,18 @@ sklm: {
"sshPortDesc": "Laissez vide pour la valeur par défaut de ssh (22).",
"sshIdentityFile": "Fichier d'identité",
"sshIdentityFileDesc": "Chemin de la clé privée ; laissez vide pour que l'agent et ~/.ssh/config décident.",
+ "sshAuthMode": "Authentification",
+ "sshAuthModeDesc": "Utilisez votre propre clé SSH ou agent, ou authentifiez-vous par mot de passe.",
+ "sshAuthKey": "Clé SSH",
+ "sshAuthPassword": "Mot de passe",
+ "sshPassword": "Mot de passe",
+ "sshPasswordDesc": "Transmis au client ssh par un assistant askpass, jamais sur la ligne de commande.",
+ "sshPasswordPlaceholder": "Votre mot de passe de connexion",
+ "sshShowPassword": "Afficher le mot de passe",
+ "sshHidePassword": "Masquer le mot de passe",
+ "sshPasswordStored": "Enregistré dans le trousseau du système pour que cet hôte se reconnecte après un redémarrage.",
"sshAction": "Installer et apparier",
+ "sshActionHint": "Installe pi-host sur l'hôte et l'apparie à ce bureau.",
"sshRunning": "Installation…",
"sshSucceeded": "{{label}} installé et apparié.",
"sshFailed": "Échec de l'installation : {{message}}",
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index 412e9dd31..2545ec222 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -828,6 +828,7 @@ sklm: {
removed: "{{label}} 제거됨.",
removeFailed: "제거 실패: {{message}}",
pairTitle: "새 호스트 페어링",
+ pairBody: "직접 실행 중인 pi-host라면: RACP URL과 시작 출력의 페어링 토큰을 붙여 넣으세요.",
pair: "페어링",
pairing: "페어링 중…",
pairAction: "추가",
@@ -844,7 +845,7 @@ sklm: {
"pi-host 부트스트랩 출력의 일회용 ppt1.* 토큰. 페어링 시 소비됩니다.",
sshTitle: "서버에 설치(SSH)",
sshBody:
- "PI-Desktop은 이미 ssh로 접속할 수 있는 머신에 pi-host를 설치하고, 릴리스가 공개한 체크섬을 검증한 뒤 루프백에서 시작해 그와 페어링합니다. 직접 가진 SSH 키로 인증하며 비밀번호는 저장되지 않습니다.",
+ "PI-Desktop은 이미 ssh로 접속할 수 있는 머신에 pi-host를 설치하고 루프백 터널을 유지합니다. 직접 가진 ssh 설정과 에이전트가 그대로 적용되며, 키 대신 로그인 비밀번호를 사용할 수도 있습니다.",
sshHost: "SSH 호스트",
sshHostDesc: "ssh가 받는 그대로의 호스트 이름 또는 주소입니다.",
sshHostPlaceholder: "build-box.local",
@@ -854,7 +855,18 @@ sklm: {
sshPortDesc: "비워 두면 ssh 기본값(22)을 사용합니다.",
sshIdentityFile: "ID 파일",
sshIdentityFileDesc: "개인 키 경로입니다. 비워 두면 에이전트와 ~/.ssh/config가 결정합니다.",
+ sshAuthMode: "인증",
+ sshAuthModeDesc: "직접 가진 SSH 키나 에이전트를 사용하거나 비밀번호로 인증합니다.",
+ sshAuthKey: "SSH 키",
+ sshAuthPassword: "비밀번호",
+ sshPassword: "비밀번호",
+ sshPasswordDesc: "askpass 도우미를 통해 ssh 클라이언트로 전달되며 명령줄에는 나타나지 않습니다.",
+ sshPasswordPlaceholder: "로그인 비밀번호",
+ sshShowPassword: "비밀번호 표시",
+ sshHidePassword: "비밀번호 숨기기",
+ sshPasswordStored: "OS 키체인에 저장되어 다시 시작한 뒤에도 이 호스트가 다시 연결됩니다.",
sshAction: "설치 및 페어링",
+ sshActionHint: "호스트에 pi-host를 설치하고 이 데스크톱과 페어링합니다.",
sshRunning: "설치 중…",
sshSucceeded: "{{label}} 설치 및 페어링됨.",
sshFailed: "설치 실패: {{message}}",
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index 71e3b2159..a307e7758 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -828,6 +828,7 @@ sklm: {
removed: "{{label}} kaldırıldı.",
removeFailed: "Kaldırma başarısız: {{message}}",
pairTitle: "Yeni ana bilgisayar eşle",
+ pairBody: "Kendinizin çalıştırdığı bir pi-host için: RACP URL'sini ve başlangıç çıktısındaki eşleşme belirtecini yapıştırın.",
pair: "Eşle",
pairing: "Eşleşiyor…",
pairAction: "Ekle",
@@ -844,7 +845,7 @@ sklm: {
"pi-host önyükleme çıktısından tek kullanımlık ppt1.* belirteci. Eşleşme sırasında tüketilir.",
sshTitle: "Bir sunucuya kurun (SSH)",
sshBody:
- "PI-Desktop, ssh ile zaten erişebildiğiniz bir makineye pi-host kurar, sürümün yayımladığı sağlama toplamını doğrular, geri döngüde başlatır ve onunla eşleşir. Kimlik doğrulamayı kendi SSH anahtarlarınız yapar — hiçbir parola saklanmaz.",
+ "PI-Desktop, ssh ile zaten erişebildiğiniz bir makineye pi-host kurar ve ona geri döngü tüneli tutar. Kendi ssh yapılandırmanız ve aracınız geçerlidir; anahtar yerine oturum açma parolası da kullanılabilir.",
sshHost: "SSH ana bilgisayarı",
sshHostDesc: "Ana bilgisayar adı veya adresi, ssh'in aldığı haliyle.",
sshHostPlaceholder: "build-box.local",
@@ -854,7 +855,18 @@ sklm: {
sshPortDesc: "ssh varsayılanı (22) için boş bırakın.",
sshIdentityFile: "Kimlik dosyası",
sshIdentityFileDesc: "Özel anahtar yolu; aracı ve ~/.ssh/config karar versin diye boş bırakın.",
+ sshAuthMode: "Kimlik doğrulama",
+ sshAuthModeDesc: "Kendi SSH anahtarınızı veya aracınızı kullanın ya da parolayla kimlik doğrulayın.",
+ sshAuthKey: "SSH anahtarı",
+ sshAuthPassword: "Parola",
+ sshPassword: "Parola",
+ sshPasswordDesc: "ssh istemcisine askpass yardımcısı üzerinden verilir, komut satırında asla görünmez.",
+ sshPasswordPlaceholder: "Oturum açma parolanız",
+ sshShowPassword: "Parolayı göster",
+ sshHidePassword: "Parolayı gizle",
+ sshPasswordStored: "Yeniden başlatmadan sonra bu ana bilgisayarın yeniden bağlanabilmesi için işletim sistemi anahtarlığında saklanır.",
sshAction: "Kur ve eşle",
+ sshActionHint: "pi-host'u ana bilgisayara kurar ve bu masaüstüyle eşler.",
sshRunning: "Kuruluyor…",
sshSucceeded: "{{label}} kuruldu ve eşlendi.",
sshFailed: "Kurulum başarısız: {{message}}",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index 5df8bdf29..46715a566 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -817,6 +817,7 @@ sklm: {
removed: "已移除 {{label}}。",
removeFailed: "移除失败:{{message}}",
pairTitle: "配对新主机",
+ pairBody: "如果你已自行运行 pi-host:粘贴它的 RACP 地址和启动输出中的配对令牌。",
pair: "配对",
pairing: "配对中…",
pairAction: "添加",
@@ -833,7 +834,7 @@ sklm: {
"来自 pi-host 引导输出的一次性 ppt1.* 令牌,配对后即消耗。",
sshTitle: "在服务器上安装(SSH)",
sshBody:
- "PI-Desktop 会在你已能用 ssh 登录的机器上安装 pi-host,校验发布方公布的 checksum,在回环上启动并与它配对。认证使用你自己的 SSH 密钥,不保存任何密码。",
+ "PI-Desktop 会在你已能用 ssh 登录的机器上安装 pi-host,并保持一条回环隧道。认证沿用你自己的 ssh 配置与 agent;也可以用登录密码代替密钥。",
sshHost: "SSH 主机",
sshHostDesc: "主机名或地址,按 ssh 的原样传入。",
sshHostPlaceholder: "build-box.local",
@@ -843,7 +844,18 @@ sklm: {
sshPortDesc: "留空使用 ssh 默认值(22)。",
sshIdentityFile: "私钥文件",
sshIdentityFileDesc: "私钥路径;留空则由 agent 与 ~/.ssh/config 决定。",
+ sshAuthMode: "认证方式",
+ sshAuthModeDesc: "使用你自己的 SSH 密钥或 agent,也可以改用密码认证。",
+ sshAuthKey: "SSH 密钥",
+ sshAuthPassword: "密码",
+ sshPassword: "密码",
+ sshPasswordDesc: "通过 askpass 助手交给 ssh 客户端,不会出现在命令行上。",
+ sshPasswordPlaceholder: "你的登录密码",
+ sshShowPassword: "显示密码",
+ sshHidePassword: "隐藏密码",
+ sshPasswordStored: "保存在系统钥匙串中,主机在重启后也能重新连接。",
sshAction: "安装并配对",
+ sshActionHint: "在目标主机上安装 pi-host,并与本桌面配对。",
sshRunning: "安装中…",
sshSucceeded: "已安装并配对 {{label}}。",
sshFailed: "安装失败:{{message}}",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index 3a329990c..21e9f4c74 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -817,6 +817,7 @@ sklm: {
removed: "已移除 {{label}}。",
removeFailed: "移除失敗:{{message}}",
pairTitle: "配對新主機",
+ pairBody: "如果你已自行執行 pi-host:貼上它的 RACP 位址與啟動輸出中的配對權杖。",
pair: "配對",
pairing: "配對中…",
pairAction: "新增",
@@ -833,7 +834,7 @@ sklm: {
"來自 pi-host 引導輸出的一次性 ppt1.* 權杖,配對後即消耗。",
sshTitle: "在伺服器上安裝(SSH)",
sshBody:
- "PI-Desktop 會在你已能用 ssh 登入的機器上安裝 pi-host,校驗發行方公布的 checksum,在迴環上啟動並與它配對。認證使用你自己的 SSH 金鑰,不會儲存任何密碼。",
+ "PI-Desktop 會在你已能用 ssh 登入的機器上安裝 pi-host,並保持一條迴環通道。認證沿用你自己的 ssh 設定與 agent;也可以用登入密碼代替金鑰。",
sshHost: "SSH 主機",
sshHostDesc: "主機名稱或位址,與 ssh 收到的原樣相同。",
sshHostPlaceholder: "build-box.local",
@@ -843,7 +844,18 @@ sklm: {
sshPortDesc: "留空使用 ssh 預設值(22)。",
sshIdentityFile: "私密金鑰檔案",
sshIdentityFileDesc: "私密金鑰路徑;留空則由 agent 與 ~/.ssh/config 決定。",
+ sshAuthMode: "認證方式",
+ sshAuthModeDesc: "使用你自己的 SSH 金鑰或 agent,也可以改用密碼認證。",
+ sshAuthKey: "SSH 金鑰",
+ sshAuthPassword: "密碼",
+ sshPassword: "密碼",
+ sshPasswordDesc: "透過 askpass 輔助程式交給 ssh 用戶端,不會出現在命令列上。",
+ sshPasswordPlaceholder: "你的登入密碼",
+ sshShowPassword: "顯示密碼",
+ sshHidePassword: "隱藏密碼",
+ sshPasswordStored: "儲存在系統鑰匙圈中,主機在重新啟動後也能重新連線。",
sshAction: "安裝並配對",
+ sshActionHint: "在目標主機上安裝 pi-host,並與本桌面配對。",
sshRunning: "安裝中…",
sshSucceeded: "已安裝並配對 {{label}}。",
sshFailed: "安裝失敗:{{message}}",
diff --git a/packages/shared/src/types/remote-host.ts b/packages/shared/src/types/remote-host.ts
index 6531a2a28..acd739575 100644
--- a/packages/shared/src/types/remote-host.ts
+++ b/packages/shared/src/types/remote-host.ts
@@ -19,10 +19,26 @@
*/
export type RemoteHostTransport = "direct" | "ssh";
+/**
+ * How the desktop authenticates the SSH session itself.
+ *
+ * - `key`: the user's agent, `~/.ssh/config`, and identity files — the only
+ * mode that existed before password auth, and still the default.
+ * - `password`: the desktop supplies a login password through OpenSSH's
+ * askpass helper. The secret is never an `ssh` argument and never appears in
+ * a renderer payload; it is stored encrypted (see `RemoteHostSshMetadata`).
+ */
+export type RemoteHostSshAuth = "key" | "password";
+
/**
* The SSH descriptor a bootstrapped host reconnects through. Persisted in the
* host record so the forward can be re-established on the next launch without
* another bootstrap.
+ *
+ * The password for an `auth: "password"` descriptor is deliberately *not* part
+ * of this shape: this type is persisted in plaintext metadata and is echoed
+ * back to the renderer inside `RemoteHostBootstrapResult`. The secret lives in
+ * a separate encrypted record field instead.
*/
export type RemoteHostSshMetadata = {
/** Host name or address as `ssh` receives it (no `user@` prefix). */
@@ -33,6 +49,8 @@ export type RemoteHostSshMetadata = {
user?: string;
/** `ssh -i` value; absent means the agent and `~/.ssh/config` decide. */
identityFile?: string;
+ /** Absent means `key`, so descriptors written before password auth read back unchanged. */
+ auth?: RemoteHostSshAuth;
/** `pi-host`'s loopback port on the remote machine. */
remotePort: number;
/** Release version the bootstrap installed, checked against `APP_VERSION`. */
@@ -100,6 +118,15 @@ export type RemoteHostBootstrapRequest = {
remotePort?: number;
/** Optional stable routing key; absent means the desktop mints one. */
hostKey?: string;
+ /**
+ * SSH login password, when the user chose password auth instead of a key.
+ * Absent keeps the key/agent path byte-for-byte unchanged. It is passed to
+ * the `ssh` client through an askpass helper, never as an argument, and is
+ * persisted encrypted with the OS keychain so the next launch can reconnect.
+ * A newline cannot be expressed — OpenSSH reads the helper's answer up to the
+ * first line break — so such a value is rejected with `INVALID_ARGUMENT`.
+ */
+ password?: string;
};
export type RemoteHostBootstrapResult = {