dsql-admin/dsql-app/docker/setup/(functions)/setup-ssh.ts

25 lines
610 B
TypeScript
Raw Normal View History

2025-01-13 21:50:42 +00:00
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!");
}