feat: ssh key type and whitespaces

This commit is contained in:
Lorenzo Migliorero
2024-07-25 23:32:52 +02:00
parent 12bd017d07
commit 2724336cad
6 changed files with 94 additions and 49 deletions

View File

@@ -10,16 +10,12 @@ const readSSHKey = async (id: string) => {
}
return {
privateKey: fs
.readFileSync(path.join(SSH_PATH, `${id}_rsa`), {
encoding: "utf-8",
})
.trim(),
publicKey: fs
.readFileSync(path.join(SSH_PATH, `${id}_rsa.pub`), {
encoding: "utf-8",
})
.trim(),
privateKey: fs.readFileSync(path.join(SSH_PATH, `${id}_rsa`), {
encoding: "utf-8",
}),
publicKey: fs.readFileSync(path.join(SSH_PATH, `${id}_rsa.pub`), {
encoding: "utf-8",
}),
};
} catch (error) {
throw error;
@@ -47,7 +43,7 @@ export const saveSSHKey = async (
publicKeyStream.end();
};
export const generateSSHKey = async () => {
export const generateSSHKey = async (type: "rsa" | "ed25519" = "rsa") => {
const applicationDirectory = SSH_PATH;
if (!fs.existsSync(applicationDirectory)) {
@@ -66,7 +62,7 @@ export const generateSSHKey = async () => {
const args = [
"-t",
"rsa",
type,
"-b",
"4096",
"-C",