dsql-admin/dsql-app/docker/setup/(functions)/setup-ssh.ts
Benjamin Toby a3440692a9 Updates
2025-01-13 22:50:42 +01:00

25 lines
610 B
TypeScript

import { $ } from "bun";
import fs from "node:fs";
import execute from "../(utils)/execute";
export default async function setupSSH() {
console.log("Generating SSH keys ...");
const KEY_NAME = "dsql";
const OUTPUT_DIR = "/ssh";
const PASSPHRASE = "";
execute(`mkdir -p "${OUTPUT_DIR}"`);
const KEY_PATH = `${OUTPUT_DIR}/${KEY_NAME}`;
if (!fs.existsSync(KEY_PATH)) {
console.log("Generating SSH keypair...");
execute(
`ssh-keygen -t rsa -b 4096 -f "${KEY_PATH}" -N "${PASSPHRASE}" -q`
);
}
console.log("SSH keys Setup Complete!");
}