mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
32 lines
864 B
TypeScript
32 lines
864 B
TypeScript
import { execAsync, paths } from "@dokploy/server";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import fs from "node:fs";
|
|
|
|
export const getShell = () => {
|
|
switch (os.platform()) {
|
|
case "win32":
|
|
return "powershell.exe";
|
|
case "darwin":
|
|
return "zsh";
|
|
default:
|
|
return "bash";
|
|
}
|
|
};
|
|
|
|
/** Returns private SSH key for dokploy local server terminal. Uses already created SSH key or generates a new SSH key.
|
|
*/
|
|
export const setupLocalServerSSHKey = async () => {
|
|
const { SSH_PATH } = paths(true);
|
|
const sshKeyPath = path.join(SSH_PATH, "auto_generated-dokploy-local");
|
|
|
|
if (!fs.existsSync(sshKeyPath)) {
|
|
// Generate new SSH key if it hasn't been created yet
|
|
await execAsync(`ssh-keygen -t rsa -b 4096 -f ${sshKeyPath} -N "" -C "dokploy-local-access"`);
|
|
}
|
|
|
|
const privateKey = fs.readFileSync(sshKeyPath, "utf8");
|
|
|
|
return privateKey;
|
|
};
|