diff --git a/server/src/config.ts b/server/src/config.ts index cdcbcc9..bebb46b 100644 --- a/server/src/config.ts +++ b/server/src/config.ts @@ -2,7 +2,6 @@ import validator from 'validator' import { config as dotenvConfig } from 'dotenv' import path from 'path' import fs from 'fs' -import { loadOrCreateKeyPair } from './utils/crypto.js' import { get } from './utils/env.js' // Import dotenv and load ../.env @@ -38,11 +37,6 @@ function createConfig() { const backendUrl = get('BACKEND_URL', `http://host.docker.internal:${port}`) const url = new URL(baseUrl) const projectRoot = getProjectRoot() - const keypairPath = get( - 'KEYPAIR_PATH', - path.join(projectRoot, 'config', 'ssh_key') - ) - const keypair = loadOrCreateKeyPair(keypairPath) return { host, @@ -85,8 +79,6 @@ function createConfig() { mountQuest: !isProduction && process.env.MOUNT_QUEST === 'true', mountCLI: !isProduction && process.env.MOUNT_CLI === 'true', hostProjectRoot: get('HOST_PROJECT_ROOT', projectRoot), - keypairPath, - keypair, }, log: { diff --git a/server/src/utils/crypto.ts b/server/src/utils/crypto.ts deleted file mode 100644 index 7f6ed0f..0000000 --- a/server/src/utils/crypto.ts +++ /dev/null @@ -1,39 +0,0 @@ -import fs from 'fs' -import path from 'path' -import ssh2 from 'ssh2' - -const { - utils: { generateKeyPairSync }, -} = ssh2 - -type KeyPair = { - privateKey: string - publicKey: string -} - -export function loadOrCreateKeyPair(privateKeyPath: string): KeyPair { - const publicKeyPath = `${privateKeyPath}.pub` - if (fs.existsSync(privateKeyPath) && fs.existsSync(publicKeyPath)) { - const privateKey = fs.readFileSync(privateKeyPath, 'utf8') - const publicKey = fs.readFileSync(publicKeyPath, 'utf8') - return { privateKey, publicKey } - } - const dir = path.dirname(privateKeyPath) - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir, { recursive: true }) - } - const keyPair = generateKeyPair() - fs.writeFileSync(privateKeyPath, keyPair.privateKey, { - mode: 0o600, - }) - fs.writeFileSync(publicKeyPath, keyPair.publicKey, { - mode: 0o600, - }) - return keyPair -} - -export function generateKeyPair(): KeyPair { - const { private: privateKey, public: publicKey } = - generateKeyPairSync('ed25519') - return { privateKey, publicKey } -} diff --git a/server/tests/utils/crypto.test.ts b/server/tests/utils/crypto.test.ts deleted file mode 100644 index 4c4b17f..0000000 --- a/server/tests/utils/crypto.test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { generateKeyPair } from '../../src/utils/crypto' - -describe('generateKeyPair', () => { - it('should generate a key pair', () => { - const keyPair = generateKeyPair() - expect(keyPair).toHaveProperty('privateKey') - expect(keyPair).toHaveProperty('publicKey') - }) -})