fixes and improvements
This commit is contained in:
@@ -81,6 +81,7 @@ function MachineEditor({
|
||||
isValidatingSSH,
|
||||
sshValidationMessage,
|
||||
sshValidationError,
|
||||
sshValidationStatus,
|
||||
}: {
|
||||
title: string;
|
||||
hint?: string;
|
||||
@@ -95,6 +96,7 @@ function MachineEditor({
|
||||
isValidatingSSH: boolean;
|
||||
sshValidationMessage: string;
|
||||
sshValidationError: string;
|
||||
sshValidationStatus: string;
|
||||
}) {
|
||||
const draft = machine;
|
||||
const setDraft = onChange;
|
||||
@@ -429,10 +431,15 @@ function MachineEditor({
|
||||
{!isLocal && (
|
||||
<Stack spacing={1}>
|
||||
<Alert severity="info">
|
||||
Validate SSH before saving: this records the first trusted host key
|
||||
in the backend-managed known_hosts file, then checks SSH auth.
|
||||
Validate SSH before saving: this records the first trusted host
|
||||
key in the backend-managed known_hosts file, then checks SSH
|
||||
auth.
|
||||
</Alert>
|
||||
<Stack direction="row" spacing={1} sx={{ flexWrap: "wrap" }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={1}
|
||||
sx={{ flexWrap: "wrap", alignItems: "center" }}
|
||||
>
|
||||
<Button
|
||||
variant="outlined"
|
||||
onClick={onValidateSSH}
|
||||
@@ -446,6 +453,9 @@ function MachineEditor({
|
||||
? "Validating SSH..."
|
||||
: "Validate SSH + trust host"}
|
||||
</Button>
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
SSH status: {sshValidationStatus || "Not tested yet"}
|
||||
</Typography>
|
||||
</Stack>
|
||||
{sshValidationMessage && (
|
||||
<Alert severity="success">{sshValidationMessage}</Alert>
|
||||
@@ -578,7 +588,11 @@ function SSHKeyManager({ sshKeys }: { sshKeys: SSHKey[] }) {
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Stack direction="row" spacing={1} sx={{ flexWrap: "wrap" }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={1}
|
||||
sx={{ flexWrap: "wrap", alignItems: "center" }}
|
||||
>
|
||||
<Button
|
||||
variant="contained"
|
||||
disabled={saveKey.isPending}
|
||||
@@ -870,6 +884,7 @@ export function Settings() {
|
||||
const [tab, setTab] = useState<SettingsTab>("machines");
|
||||
const [sshValidationMessage, setSSHValidationMessage] = useState("");
|
||||
const [sshValidationError, setSSHValidationError] = useState("");
|
||||
const [sshValidationStatus, setSSHValidationStatus] = useState("");
|
||||
const [machineDialogOpen, setMachineDialogOpen] = useState(false);
|
||||
const [machineDraft, setMachineDraft] = useState<MonitoringMachineInput>(
|
||||
emptyMachine(),
|
||||
@@ -892,6 +907,7 @@ export function Settings() {
|
||||
const clearSSHValidation = () => {
|
||||
setSSHValidationMessage("");
|
||||
setSSHValidationError("");
|
||||
setSSHValidationStatus("");
|
||||
};
|
||||
const beginLocal = () => {
|
||||
clearSSHValidation();
|
||||
@@ -931,10 +947,25 @@ export function Settings() {
|
||||
try {
|
||||
const result = await testMachineSSH.mutateAsync(machineDraft);
|
||||
setSSHValidationMessage(result.message);
|
||||
} catch (error) {
|
||||
setSSHValidationError(
|
||||
error instanceof Error ? error.message : String(error),
|
||||
setSSHValidationStatus(
|
||||
result.known_hosts_updated
|
||||
? "Host key trusted and SSH auth succeeded."
|
||||
: "Host key already trusted and SSH auth succeeded.",
|
||||
);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
setSSHValidationError(message);
|
||||
const lowered = message.toLowerCase();
|
||||
if (lowered.includes("protocol banner")) {
|
||||
setSSHValidationStatus("SSH banner not received.");
|
||||
} else if (
|
||||
lowered.includes("no authentication methods available") ||
|
||||
lowered.includes("authentication failed")
|
||||
) {
|
||||
setSSHValidationStatus("SSH authentication failed.");
|
||||
} else {
|
||||
setSSHValidationStatus("SSH validation failed.");
|
||||
}
|
||||
}
|
||||
};
|
||||
return (
|
||||
@@ -1283,6 +1314,7 @@ export function Settings() {
|
||||
isValidatingSSH={testMachineSSH.isPending}
|
||||
sshValidationMessage={sshValidationMessage}
|
||||
sshValidationError={sshValidationError}
|
||||
sshValidationStatus={sshValidationStatus}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogFooter
|
||||
|
||||
Reference in New Issue
Block a user