refactor: make default value for skip host key check to false

This commit is contained in:
Nicolas Meienberger 2025-12-28 13:31:17 +01:00
parent 8c243a0280
commit 2bee6c0751
6 changed files with 4 additions and 6 deletions

View file

@ -58,7 +58,7 @@ const defaultValuesForType = {
azure: { backend: "azure" as const, compressionMode: "auto" as const },
rclone: { backend: "rclone" 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 = ({

View file

@ -100,7 +100,6 @@ export const SftpRepositoryForm = ({ form }: Props) => {
<FormField
control={form.control}
name="skipHostKeyCheck"
defaultValue={true}
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm">
<div className="space-y-0.5">

View file

@ -46,7 +46,7 @@ const defaultValuesForType = {
smb: { backend: "smb" as const, port: 445, vers: "3.0" as const },
webdav: { backend: "webdav" as const, port: 80, ssl: false, path: "/webdav" },
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) => {

View file

@ -118,7 +118,6 @@ export const SFTPForm = ({ form }: Props) => {
<FormField
control={form.control}
name="skipHostKeyCheck"
defaultValue={true}
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm">
<div className="space-y-0.5">

View file

@ -60,7 +60,7 @@ const mount = async (config: BackendConfig, mountPath: string) => {
"gid=1000",
];
if (config.skipHostKeyCheck) {
if (config.skipHostKeyCheck || !config.knownHosts) {
options.push("StrictHostKeyChecking=no", "UserKnownHostsFile=/dev/null");
} else if (config.knownHosts) {
const knownHostsPath = getKnownHostsPath(mountPath);

View file

@ -186,7 +186,7 @@ export const buildEnv = async (config: RepositoryConfig) => {
keyPath,
];
if (config.skipHostKeyCheck) {
if (config.skipHostKeyCheck || !config.knownHosts) {
sshArgs.push("-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null");
} else if (config.knownHosts) {
const knownHostsPath = path.join("/tmp", `zerobyte-known-hosts-${crypto.randomBytes(8).toString("hex")}`);