Debian Codegraph @

pkg/lib/cockpit-connect-ssh.tsx

raw
1 /*
2 * Copyright (C) 2024 Red Hat, Inc.
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6 /* Dialogs for setting up SSH connection to a remote host. The central and only exported function here is
7 * connect_host() at the very bottom of this file.
8 */
9
10 import React, { useState } from 'react';
11
12 import { Alert } from "@patternfly/react-core/dist/esm/components/Alert/index.js";
13 import { Button } from "@patternfly/react-core/dist/esm/components/Button/index.js";
14 import { Checkbox } from "@patternfly/react-core/dist/esm/components/Checkbox/index.js";
15 import { ClipboardCopy } from "@patternfly/react-core/dist/esm/components/ClipboardCopy/index.js";
16 import { ExpandableSection } from "@patternfly/react-core/dist/esm/components/ExpandableSection/index.js";
17 import { Form, FormGroup } from "@patternfly/react-core/dist/esm/components/Form/index.js";
18 import {
19 Modal, ModalBody, ModalFooter, ModalHeader
20 } from '@patternfly/react-core/dist/esm/components/Modal/index.js';
21 import { Popover } from "@patternfly/react-core/dist/esm/components/Popover/index.js";
22 import { Radio } from "@patternfly/react-core/dist/esm/components/Radio/index.js";
23 import { Stack } from "@patternfly/react-core/dist/esm/layouts/Stack/index.js";
24 import { TextInput } from "@patternfly/react-core/dist/esm/components/TextInput/index.js";
25 import { OutlinedQuestionCircleIcon } from "@patternfly/react-icons";
26
27 import cockpit from "cockpit";
28 import * as credentials from "credentials";
29 import { Dialogs, DialogResult } from "dialogs";
30 import { FormHelper } from "cockpit-components-form-helper";
31 import { ModalError } from "cockpit-components-inline-notification.jsx";
32
33 // @ts-expect-error: magic verbatim string import, not a JS module
34 import ssh_show_default_key_sh from "./ssh-show-default-key.sh";
35 // @ts-expect-error: magic verbatim string import, not a JS module
36 import ssh_add_key_sh from "./ssh-add-key.sh";
37
38 const _ = cockpit.gettext;
39
40 function debug(...args: unknown[]) {
41 if (window.debugging === "all" || window.debugging?.includes("connect-ssh"))
42 console.debug("cockpit-connect-ssh:", ...args);
43 }
44
45 type Address = {
46 address: string,
47 port?: number,
48 user?: string
49 };
50
51 function split_connection_string(conn_to: string): Address {
52 const addr: Address = { address: "" };
53 let user_spot = -1;
54 let port_spot = -1;
55
56 if (conn_to) {
57 user_spot = conn_to.lastIndexOf('@');
58 port_spot = conn_to.lastIndexOf(':');
59 }
60
61 if (user_spot > 0) {
62 addr.user = conn_to.substring(0, user_spot);
63 conn_to = conn_to.substring(user_spot + 1);
64 port_spot = conn_to.lastIndexOf(':');
65 }
66
67 if (port_spot > -1) {
68 const port = parseInt(conn_to.substring(port_spot + 1), 10);
69 if (!isNaN(port)) {
70 addr.port = port;
71 conn_to = conn_to.substring(0, port_spot);
72 }
73 }
74
75 addr.address = conn_to;
76 return addr;
77 }
78
79 function try_connect(options: cockpit.ChannelOptions): Promise<void> {
80 return new Promise((resolve, reject) => {
81 // `binary: false` is the default, but https://github.com/microsoft/TypeScript/issues/58977
82 const client = cockpit.channel({ ...options, payload: "echo", binary: false });
83 client.send("x");
84 client.addEventListener("message", () => {
85 resolve();
86 client.close();
87 });
88 client.addEventListener("close", (_ev, options) => reject(options));
89 });
90 }
91
92 const UnknownHostDialog = ({ host, error, dialogResult }: {
93 host: string,
94 error: cockpit.JsonObject,
95 dialogResult: DialogResult<void>,
96 }) => {
97 const [inProgress, setInProgress] = useState(false);
98 const [verifyExpanded, setVerifyExpanded] = useState(false);
99 const [dialogError, setDialogError] = useState("");
100
101 cockpit.assert(error["host-key"] && error["host-fingerprint"],
102 "UnknownHostDialog needs a host-key and host-fingerprint in error");
103 const host_key: string = (error["host-key"] as string).trim();
104 const host_fp = error["host-fingerprint"] as string;
105
106 const key_type = host_key.split(" ")[1];
107 cockpit.assert(key_type, "host-key did not include a key type");
108
109 const scan_cmd = `ssh-keyscan -t ${key_type} localhost | ssh-keygen -lf -`;
110
111 const address = split_connection_string(host);
112
113 const title = cockpit.format(error.problem === "invalid-hostkey" ? _("$0 key changed") : _("Unknown host: $0"),
114 address.address);
115 const submitText = _("Trust and add host");
116 let body = null;
117 if (error.problem === "invalid-hostkey") {
118 body = <>
119 <Alert variant='danger' isInline title={_("Changed keys are often the result of an operating system reinstallation. However, an unexpected change may indicate a third-party attempt to intercept your connection.")} />
120 <p>{_("To ensure that your connection is not intercepted by a malicious third-party, please verify the host key fingerprint:")}</p>
121 <ClipboardCopy isReadOnly hoverTip={_("Copy")} clickTip={_("Copied")} className="hostkey-fingerprint pf-v6-u-font-family-monospace">{host_fp}</ClipboardCopy>
122 <p className="hostkey-type">({key_type})</p>
123 <p>{cockpit.format(_("To verify a fingerprint, run the following on $0 while physically sitting at the machine or through a trusted network:"), address.address)}</p>
124 <ClipboardCopy isReadOnly hoverTip={_("Copy")} clickTip={_("Copied")} className="hostkey-verify-help-cmds pf-v6-u-font-family-monospace">{scan_cmd}</ClipboardCopy>
125 <p>{_("The resulting fingerprint is fine to share via public methods, including email.")}</p>
126 <p>{_("If the fingerprint matches, click 'Trust and add host'. Otherwise, do not connect and contact your administrator.")}</p>
127 </>;
128 } else {
129 const fingerprint_help = <Popover bodyContent={
130 _("The resulting fingerprint is fine to share via public methods, including email. If you are asking someone else to do the verification for you, they can send the results using any method.")}>
131 <OutlinedQuestionCircleIcon />
132 </Popover>;
133 body = <>
134 <p>{cockpit.format(_("You are connecting to $0 for the first time."), address.address)}</p>
135 <ExpandableSection toggleText={ _("Verify fingerprint") }
136 isExpanded={verifyExpanded}
137 onToggle={(_ev, value) => setVerifyExpanded(value) }>
138 <div>{_("Run this command over a trusted network or physically on the remote machine:")}</div>
139 <ClipboardCopy isReadOnly hoverTip={_("Copy")} clickTip={_("Copied")} className="hostkey-verify-help hostkey-verify-help-cmds pf-v6-u-font-family-monospace">{scan_cmd}</ClipboardCopy>
140 <div>{_("The fingerprint should match:")} {fingerprint_help}</div>
141 <ClipboardCopy isReadOnly hoverTip={_("Copy")} clickTip={_("Copied")} className="hostkey-verify-help hostkey-fingerprint pf-v6-u-font-family-monospace">{host_fp}</ClipboardCopy>
142 </ExpandableSection>
143 </>;
144 }
145
146 const onAddKey = async () => {
147 setInProgress(true);
148 debug("onAddKey", error);
149 try {
150 await cockpit.script(ssh_add_key_sh, [host_key, "known_hosts"], { err: "message" });
151 dialogResult.resolve();
152 } catch (ex) { // not-covered: OS error
153 setDialogError((ex as cockpit.BasicError).toString()); // not-covered: OS error
154 setInProgress(false); // not-covered: OS error
155 }
156 };
157
158 return (
159 <Modal id="ssh-unknown-host-dialog" isOpen
160 position="top" variant="medium"
161 onClose={() => dialogResult.reject("cancel")}
162 >
163 <ModalHeader title={title} />
164 <ModalBody>
165 <Stack hasGutter>
166 { dialogError && <ModalError dialogError={dialogError} />}
167 {body}
168 </Stack>
169 </ModalBody>
170 <ModalFooter>
171 <Button variant="primary" onClick={onAddKey} isLoading={inProgress} isDisabled={inProgress}>
172 { submitText }
173 </Button>
174 <Button variant="link" className="btn-cancel" onClick={() => dialogResult.reject("cancel")}>
175 { _("Cancel") }
176 </Button>
177 </ModalFooter>
178 </Modal>
179 );
180 };
181
182 interface ChangeAuthProps {
183 host: string;
184 user?: string;
185 error: cockpit.JsonObject,
186 dialogResult: DialogResult<void>;
187 }
188
189 interface ChangeAuthState {
190 auth: string;
191 setup_ssh: boolean,
192 custom_password: string;
193 custom_password_error: string;
194 locked_identity_password: string;
195 locked_identity_password_error: string;
196 login_setup_new_key_password: string;
197 login_setup_new_key_password2: string;
198 login_setup_new_key_password2_error: string;
199 user: cockpit.UserInfo | null;
200 default_ssh_key: { name: string, type?: string, exists: boolean, encrypted: boolean } | null;
201 identity_path: string | null;
202 in_progress: boolean; // componentDidMount changes to false once loaded
203 dialogError: string;
204 }
205
206 class ChangeAuthDialog extends React.Component<ChangeAuthProps, ChangeAuthState> {
207 constructor(props: ChangeAuthProps) {
208 super(props);
209
210 this.state = {
211 auth: "password",
212 setup_ssh: false,
213 custom_password: "",
214 custom_password_error: "",
215 locked_identity_password: "",
216 locked_identity_password_error: "",
217 login_setup_new_key_password: "",
218 login_setup_new_key_password2: "",
219 login_setup_new_key_password2_error: "",
220 user: null,
221 default_ssh_key: null,
222 identity_path: null,
223 in_progress: true, // componentDidMount changes to false once loaded
224 dialogError: "",
225 };
226
227 this.login = this.login.bind(this);
228 }
229
230 // wrapper to silence typescript's "property does not exist"
231 keys() {
232 // @ts-expect-error: "property does not exist", yes TS, that's why we add it here..
233 if (!this.__keys)
234 // @ts-expect-error: ditto
235 this.__keys = credentials.keys_instance();
236 // @ts-expect-error: ditto
237 return this.__keys;
238 }
239
240 updateIdentity() {
241 const e = this.props.error.error as string;
242 const identity_path = e?.startsWith("locked identity") ? e.split(": ")[1] : null;
243
244 this.setState({ identity_path });
245 }
246
247 async componentDidMount() {
248 try {
249 const user = await cockpit.user();
250 const output = await cockpit.script(ssh_show_default_key_sh, [], { });
251 const info = output.split("\n");
252 let default_ssh_key = null;
253 if (info[0])
254 default_ssh_key = {
255 name: info[0],
256 exists: true,
257 encrypted: info[1] === "encrypted",
258 };
259 else
260 default_ssh_key = {
261 name: user.home + "/.ssh/id_rsa",
262 type: "rsa",
263 exists: false,
264 encrypted: false,
265 };
266
267 return this.setState({ in_progress: false, default_ssh_key, user }, this.updateIdentity);
268 } catch (ex) { // not-covered: OS error
269 const dialogError = (ex as cockpit.BasicError).toString(); // not-covered: ditto
270 this.setState({ in_progress: false, dialogError }); // not-covered: ditto
271 }
272 }
273
274 componentWillUnmount() {
275 // @ts-expect-error: see keys()
276 this.__keys?.close();
277 // @ts-expect-error: see keys()
278 this.__keys = null;
279 }
280
281 getSupports() {
282 const methods = this.props.error["auth-method-results"] as cockpit.JsonObject;
283 return {
284 offer_login_password: methods.password && methods.password !== "no-server-support",
285 offer_key_password: this.state.identity_path !== null,
286 };
287 }
288
289 async maybe_create_key(passphrase: string) {
290 const key = this.state.default_ssh_key!;
291 if (!key.exists)
292 await this.keys().create(key.name, key.type, passphrase);
293 }
294
295 async authorize_key() {
296 const key = this.state.default_ssh_key!;
297 const pubkey = await this.keys().get_pubkey(key.name);
298 await cockpit.script(
299 ssh_add_key_sh, [pubkey.trim()],
300 { host: this.props.host, ...this.props.user && { user: this.props.user }, err: "message" }
301 );
302 }
303
304 async maybe_unlock_key() {
305 const { offer_login_password, offer_key_password } = this.getSupports();
306 const both = offer_login_password && offer_key_password;
307
308 if ((both && this.state.auth === "key") || (!both && offer_key_password))
309 await this.keys().load(this.state.identity_path, this.state.locked_identity_password);
310 }
311
312 async login() {
313 const options: cockpit.ChannelOptions = { host: this.props.host };
314 if (this.props.user)
315 options.user = this.props.user;
316
317 let custom_password_error = "";
318 let locked_identity_password_error = "";
319 let login_setup_new_key_password2_error = "";
320
321 const { offer_login_password, offer_key_password } = this.getSupports();
322 const both = offer_login_password && offer_key_password;
323
324 if ((both && this.state.auth === "password") || (!both && offer_login_password)) {
325 if (!this.state.custom_password)
326 custom_password_error = _("The password can not be empty");
327
328 options.password = this.state.custom_password;
329 }
330
331 if ((offer_key_password && !(both && this.state.auth === "password")) && !this.state.locked_identity_password)
332 locked_identity_password_error = _("The key password can not be empty");
333 if (this.state.setup_ssh && this.state.login_setup_new_key_password !== this.state.login_setup_new_key_password2)
334 login_setup_new_key_password2_error = _("The key passwords do not match");
335
336 this.setState({
337 custom_password_error,
338 locked_identity_password_error,
339 login_setup_new_key_password2_error,
340 });
341
342 if (custom_password_error || locked_identity_password_error || login_setup_new_key_password2_error)
343 return;
344
345 this.setState({ in_progress: true });
346
347 try {
348 await this.maybe_unlock_key();
349 await try_connect(options);
350 if (this.state.setup_ssh) {
351 await this.maybe_create_key(this.state.login_setup_new_key_password);
352 await this.authorize_key();
353 }
354 this.props.dialogResult.resolve();
355 } catch (ex) {
356 const err = ex as cockpit.JsonObject;
357 if (err.problem === "no-cockpit")
358 // this is handled in a separate dialog, and the SSH connection succeeded at this point
359 this.props.dialogResult.reject(err);
360 this.setState({ in_progress: false, dialogError: cockpit.message(err) });
361 }
362 }
363
364 render() {
365 const { offer_login_password, offer_key_password } = this.getSupports();
366 const both = offer_login_password && offer_key_password;
367
368 let offer_key_setup = true;
369 if (!this.state.default_ssh_key)
370 offer_key_setup = false;
371 else if (this.state.identity_path) {
372 // This is a locked, non-default identity that will never
373 // be loaded into the agent, so there is no point in
374 // offering to change the passphrase.
375 offer_key_setup = false;
376 }
377
378 const address = split_connection_string(this.props.host);
379 const title = cockpit.format(_("Log in to $0"), address.address);
380 const submitText = _("Log in");
381 let statement: React.ReactNode = null;
382
383 if (!offer_login_password && !offer_key_password)
384 statement = <p>{cockpit.format(_("Unable to log in to $0. The host does not accept password login or any of your SSH keys."), this.props.host)}</p>;
385 else if (offer_login_password && !offer_key_password)
386 statement = <p>{cockpit.format(_("Unable to log in to $0 using SSH key authentication. Please provide the password."), this.props.host)}</p>;
387 else if (offer_key_password && !offer_login_password)
388 statement = <p>{cockpit.format(_("The SSH key for logging in to $0 is protected by a password, and the host does not allow logging in with a password. Please provide the password of the key at $1."), this.props.host, this.state.identity_path)}</p>;
389 else if (both)
390 statement = <p>{cockpit.format(_("The SSH key for logging in to $0 is protected. You can log in with either your login password or by providing the password of the key at $1."), this.props.host, this.state.identity_path)}</p>;
391
392 let ssh_key_text = null;
393 let ssh_key_details = null;
394 if (this.state.default_ssh_key) {
395 const key = this.state.default_ssh_key.name;
396 const luser = this.state.user!.name;
397 const lhost = "localhost";
398 const afile = "~/.ssh/authorized_keys";
399 const ruser = this.props.user || address.user || this.state.user!.name;
400 if (!this.state.default_ssh_key.exists) {
401 ssh_key_text = _("Create a new SSH key and authorize it");
402 ssh_key_details = <>
403 <p>{cockpit.format(_("A new SSH key at $0 will be created for $1 on $2 and it will be added to the $3 file of $4 on $5."), key, luser, lhost, afile, ruser, address.address)}</p>
404 <FormGroup label={_("Key password")}>
405 <TextInput id="login-setup-new-key-password" onChange={(_event, value) => this.setState({ login_setup_new_key_password: value })}
406 type="password" value={this.state.login_setup_new_key_password} />
407 </FormGroup>
408 <FormGroup label={_("Confirm key password")}>
409 <TextInput id="login-setup-new-key-password2" onChange={(_event, value) => this.setState({ login_setup_new_key_password2: value })}
410 type="password" value={this.state.login_setup_new_key_password2} validated={this.state.login_setup_new_key_password2_error ? "error" : "default"} />
411 <FormHelper helperTextInvalid={this.state.login_setup_new_key_password2_error} />
412 </FormGroup>
413 </>;
414 } else {
415 ssh_key_text = _("Authorize SSH key");
416 ssh_key_details = <p>{cockpit.format(_("The SSH key $0 of $1 on $2 will be added to the $3 file of $4 on $5."), key, luser, lhost, afile, ruser, address.address)}</p>;
417 }
418 }
419
420 const body = <>
421 {statement}
422 <br />
423 {(offer_login_password || offer_key_password) &&
424 <Form isHorizontal onSubmit={ev => { ev.preventDefault(); this.login() }}>
425 {both &&
426 <FormGroup label={_("Authentication")} isInline hasNoPaddingTop>
427 <Radio name="auth-method"
428 isChecked={this.state.auth === "password"}
429 onChange={() => this.setState({ auth: "password" })}
430 id="auth-password"
431 value="password"
432 label={_("Password")} />
433 <Radio name="auth-method"
434 isChecked={this.state.auth === "key"}
435 onChange={() => this.setState({ auth: "key" })}
436 id="auth-key"
437 value="key"
438 label={_("SSH key")} />
439 </FormGroup>
440 }
441 {((both && this.state.auth === "password") || (!both && offer_login_password)) &&
442 <FormGroup label={_("Password")}>
443 <TextInput id="login-custom-password" onChange={(_event, value) => this.setState({ custom_password: value })}
444 type="password" value={this.state.custom_password} validated={this.state.custom_password_error ? "error" : "default"} />
445 <FormHelper helperTextInvalid={this.state.custom_password_error} />
446 </FormGroup>
447 }
448 {((both && this.state.auth === "key") || (!both && offer_key_password)) &&
449 <FormGroup label={_("Key password")}>
450 <TextInput id="locked-identity-password" onChange={(_event, value) => this.setState({ locked_identity_password: value })}
451 type="password" autoComplete="new-password" value={this.state.locked_identity_password} validated={this.state.locked_identity_password_error ? "error" : "default"} />
452 <FormHelper
453 helperText={cockpit.format(_("The SSH key $0 will be made available for the remainder of the session and will be available for login to other hosts as well."), this.state.identity_path)}
454 helperTextInvalid={this.state.locked_identity_password_error} />
455 </FormGroup>
456 }
457 {offer_key_setup &&
458 <FormGroup label={ _("SSH key login") } hasNoPaddingTop isInline>
459 <Checkbox onChange={(_event, checked) => this.setState({ setup_ssh: checked })}
460 isChecked={this.state.setup_ssh} id="login-setup-keys"
461 label={ssh_key_text} body={this.state.setup_ssh ? ssh_key_details : null} />
462 </FormGroup>
463 }
464 </Form>
465 }
466 </>;
467
468 const onCancel = () => this.props.dialogResult.reject("cancel");
469
470 return (
471 <Modal id="ssh-change-auth-dialog" isOpen
472 position="top" variant="medium"
473 onClose={onCancel}
474 >
475 <ModalHeader title={title} />
476 <ModalBody>
477 <Stack hasGutter>
478 { this.state.dialogError && <ModalError dialogError={this.state.dialogError} /> }
479 {body}
480 </Stack>
481 </ModalBody>
482 <ModalFooter>
483 <Button variant="primary" onClick={this.login} isLoading={this.state.in_progress}
484 isDisabled={this.state.in_progress || (!offer_login_password && !offer_key_password) || !this.state.default_ssh_key || !this.props.error}>
485 { submitText }
486 </Button>
487 <Button variant="link" className="btn-cancel" onClick={onCancel}>
488 { _("Cancel") }
489 </Button>
490 </ModalFooter>
491 </Modal>
492 );
493 }
494 }
495
496 const NotSupportedDialog = ({ host, error, dialogResult }: {
497 host: string,
498 error: cockpit.JsonObject,
499 dialogResult: DialogResult<void>,
500 }) => (
501 <Modal id="ssh-not-supported-dialog" isOpen
502 position="top" variant="medium"
503 onClose={() => dialogResult.reject(error)}
504 >
505 <ModalHeader title={_("Cockpit is not installed")} />
506 <ModalBody>
507 <Stack hasGutter>
508 <p>{cockpit.format(_("A compatible version of Cockpit is not installed on $0."), host)}</p>
509 </Stack>
510 </ModalBody>
511 <ModalFooter>
512 <Button variant="secondary" className="btn-cancel" onClick={() => dialogResult.reject(error)}>
513 { _("Close") }
514 </Button>
515 </ModalFooter>
516 </Modal>
517 );
518
519 const error_dialogs = {
520 "unknown-hostkey": UnknownHostDialog,
521 "invalid-hostkey": UnknownHostDialog,
522 "authentication-failed": ChangeAuthDialog,
523 "no-cockpit": NotSupportedDialog,
524 };
525
526 /**
527 * Set up SSH connection to a remote host
528 *
529 * Cockpit channels support running on a remote machine through SSH via the
530 * `host` channel option. This only works (without additional authentication
531 * options) if the SSH connection was already established (e.g. through the
532 * deprecated shell's "Add Host" feature), or can be established
533 * noninteractively (e.g. if you have a passwordless SSH key, or a special
534 * noninteractive configuration block in your ~/.ssh/config for the target host).
535 *
536 * For all other cases, call this function first. It shows various dialogs where
537 * the user can specify a login password or unlock their SSH key. If the user
538 * does not already have an SSH key, the dialog also offers to create one. It
539 * also offers to authorize the user's SSH key to the remote machine/user.
540 *
541 * Arguments:
542 * @dialog_context: The page's `DialogsContext`, see ./dialogs.tsx
543 * @host: Same `[user@]host[:port]` format as the channel option; must be
544 * *exactly* the same as for opening the channel afterwards
545 * @user: Same as the channel option; overrides `user@` portion of @host
546 * Returns: Nothing on success. Afterwards the SSH connection is established and
547 * you can use the `host` option in channels. Throws a "cancel"
548 * exception if the user cancelled the dialog. Most SSH errors are
549 * handled in the dialogs, but you still have to expect and check for
550 * other Cockpit errors with the usual `{ problem: "...", ... }` structure.
551 *
552 * See pkg/playground/remote.tsx for an example how to use this function.
553 *
554 * [1] https://github.com/cockpit-project/cockpit/blob/main/doc/protocol.md#command-init
555 */
556 export async function connect_host(dialog_context: Dialogs, host: string, user?: string) {
557 const options: cockpit.ChannelOptions = { host, ...user && { user } };
558 while (true) {
559 try {
560 await try_connect(options);
561 debug(host, "succeeded");
562 break;
563 } catch (_ex) {
564 const ex = _ex as cockpit.JsonObject;
565 // unknown host or changed host key → re-try with private session to get its host key
566 if ((ex.problem === "unknown-host" || ex.problem === "invalid-hostkey") && !ex["host-key"]) {
567 debug(host, "failed with unknown-host, retrying with private session");
568 options.session = "private";
569 continue;
570 } else {
571 // reset
572 delete options.session;
573 }
574
575 // @ts-expect-error: ex is untyped, and this is too much useless hassle
576 const dialog = error_dialogs[ex.problem];
577 if (dialog) {
578 debug(host, "failed with:", ex, "mapping to", dialog);
579 try {
580 const result = await dialog_context.run(dialog, { host, user, error: ex });
581 debug(host, "dialog result:", result);
582 } catch (_ex) {
583 const dialog_error = _ex as cockpit.JsonObject;
584 debug(host, "dialog", dialog, "failed with:", dialog_error);
585 if (dialog_error.problem === "no-cockpit") {
586 // avoid another SSH connection
587 await dialog_context.run(NotSupportedDialog, { host, user, error: dialog_error });
588 } else {
589 throw dialog_error;
590 }
591 }
592 } else {
593 debug(host, "terminally failed with:", ex);
594 throw ex;
595 }
596 }
597 }
598 }