Файли
openidea/src/features/ssh/index.ts
T
Deng Liuтаdengliu 41165bb8c0 fix(ssh): migrate legacy saved credentials at startup (#5786)
Host startup now moves legacy plaintext SSH passwords and key passphrases from
ssh-passwords.json into the OS credential store, without waiting for the next
SSH connection. When the move cannot finish, each workbench shows a sticky
warning with Retry migration and a confirmed Remove plaintext copy, which keeps
credentials already moved. A credential that cannot be saved stays for the
session and the requesting window is warned. An unreadable ssh-passwords.json
is set aside (renamed, never deleted) like the other secret files, so it no
longer blocks saving new credentials.

Co-authored-by: dengliu <[email protected]>
2026-11-25 19:27:09 +08:00

46 рядки
1.8 KiB
TypeScript
Неформатований Анотація Історія

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
/**
* SSH: credential prompts of `ssh` / `git` child processes (askpass) and
* Tools › Start SSH Session. The configurations live in Settings › Tools ›
* SSH Configurations.
*/
import { executeAction, registerActions } from "@/platform/actions";
import { onIdeEvent } from "@/platform/ipc";
import { registerOverlay } from "@/workbench/contributions";
import { dropAskpass, enqueueAskpass, useAskpass } from "./askpass";
import { AskpassHost } from "./AskpassDialog";
import { startPasswordMigrationNotice } from "./passwordMigration";
import { chooseSshSession, SSH_SETTINGS_PAGE, startSshSession } from "./session";
export function activate(): () => void {
const disposers = [
startPasswordMigrationNotice(),
registerOverlay({ id: "ssh.askpass", component: AskpassHost }),
onIdeEvent("askpass", (e) => enqueueAskpass({ id: e.id, prompt: e.prompt, kind: e.kind, remember: e.remember })),
onIdeEvent("askpassDone", (e) => dropAskpass(e.id)),
registerActions([
{
id: "ssh.startSession",
title: "Start SSH Session…",
description: "Opens a terminal tab connected to an SSH configuration (`arg`: its id; otherwise a chooser).",
category: "Tools",
icon: "terminal",
when: "projectOpen",
keywords: ["ssh", "remote", "terminal", "shell", "connect"],
run: ({ arg }) => (typeof arg === "string" && arg ? startSshSession(arg) : chooseSshSession()),
},
{
id: "ssh.configurations",
title: "SSH Configurations…",
category: "Tools",
icon: "settings",
keywords: ["ssh", "remote", "host"],
run: () => void executeAction("file.settings", SSH_SETTINGS_PAGE),
},
]),
];
return () => {
disposers.reverse().forEach((d) => d());
useAskpass.setState({ queue: [] });
};
}