refactor: make default value for skip host key check to false
This commit is contained in:
parent
8c243a0280
commit
2bee6c0751
6 changed files with 4 additions and 6 deletions
|
|
@ -58,7 +58,7 @@ const defaultValuesForType = {
|
||||||
azure: { backend: "azure" as const, compressionMode: "auto" as const },
|
azure: { backend: "azure" as const, compressionMode: "auto" as const },
|
||||||
rclone: { backend: "rclone" as const, compressionMode: "auto" as const },
|
rclone: { backend: "rclone" as const, compressionMode: "auto" as const },
|
||||||
rest: { backend: "rest" as const, compressionMode: "auto" as const },
|
rest: { backend: "rest" as const, compressionMode: "auto" as const },
|
||||||
sftp: { backend: "sftp" as const, compressionMode: "auto" as const, port: 22, skipHostKeyCheck: true },
|
sftp: { backend: "sftp" as const, compressionMode: "auto" as const, port: 22, skipHostKeyCheck: false },
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CreateRepositoryForm = ({
|
export const CreateRepositoryForm = ({
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,6 @@ export const SftpRepositoryForm = ({ form }: Props) => {
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="skipHostKeyCheck"
|
name="skipHostKeyCheck"
|
||||||
defaultValue={true}
|
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm">
|
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm">
|
||||||
<div className="space-y-0.5">
|
<div className="space-y-0.5">
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ const defaultValuesForType = {
|
||||||
smb: { backend: "smb" as const, port: 445, vers: "3.0" as const },
|
smb: { backend: "smb" as const, port: 445, vers: "3.0" as const },
|
||||||
webdav: { backend: "webdav" as const, port: 80, ssl: false, path: "/webdav" },
|
webdav: { backend: "webdav" as const, port: 80, ssl: false, path: "/webdav" },
|
||||||
rclone: { backend: "rclone" as const, path: "/" },
|
rclone: { backend: "rclone" as const, path: "/" },
|
||||||
sftp: { backend: "sftp" as const, port: 22, path: "/", skipHostKeyCheck: true },
|
sftp: { backend: "sftp" as const, port: 22, path: "/", skipHostKeyCheck: false },
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CreateVolumeForm = ({ onSubmit, mode = "create", initialValues, formId, loading, className }: Props) => {
|
export const CreateVolumeForm = ({ onSubmit, mode = "create", initialValues, formId, loading, className }: Props) => {
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,6 @@ export const SFTPForm = ({ form }: Props) => {
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="skipHostKeyCheck"
|
name="skipHostKeyCheck"
|
||||||
defaultValue={true}
|
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm">
|
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm">
|
||||||
<div className="space-y-0.5">
|
<div className="space-y-0.5">
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ const mount = async (config: BackendConfig, mountPath: string) => {
|
||||||
"gid=1000",
|
"gid=1000",
|
||||||
];
|
];
|
||||||
|
|
||||||
if (config.skipHostKeyCheck) {
|
if (config.skipHostKeyCheck || !config.knownHosts) {
|
||||||
options.push("StrictHostKeyChecking=no", "UserKnownHostsFile=/dev/null");
|
options.push("StrictHostKeyChecking=no", "UserKnownHostsFile=/dev/null");
|
||||||
} else if (config.knownHosts) {
|
} else if (config.knownHosts) {
|
||||||
const knownHostsPath = getKnownHostsPath(mountPath);
|
const knownHostsPath = getKnownHostsPath(mountPath);
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ export const buildEnv = async (config: RepositoryConfig) => {
|
||||||
keyPath,
|
keyPath,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (config.skipHostKeyCheck) {
|
if (config.skipHostKeyCheck || !config.knownHosts) {
|
||||||
sshArgs.push("-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null");
|
sshArgs.push("-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null");
|
||||||
} else if (config.knownHosts) {
|
} else if (config.knownHosts) {
|
||||||
const knownHostsPath = path.join("/tmp", `zerobyte-known-hosts-${crypto.randomBytes(8).toString("hex")}`);
|
const knownHostsPath = path.join("/tmp", `zerobyte-known-hosts-${crypto.randomBytes(8).toString("hex")}`);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue