From 1ff771a62a3bb3cfa1feca59d25bf6ccb7f747f9 Mon Sep 17 00:00:00 2001 From: Jakob Husu Date: Wed, 20 May 2026 11:33:12 +0200 Subject: [PATCH] Default key output to ~/.ssh/ and create the directory if needed --- keygen.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/keygen.py b/keygen.py index e84e7e4..a6921c6 100644 --- a/keygen.py +++ b/keygen.py @@ -53,6 +53,7 @@ def save_keypair( pub_path = path.with_suffix("").parent / (path.name + ".pub") + path.parent.mkdir(mode=0o700, parents=True, exist_ok=True) path.write_bytes(private_bytes) path.chmod(0o600) pub_path.write_bytes(public_bytes + b"\n") @@ -145,9 +146,9 @@ def build_parser() -> argparse.ArgumentParser: shared = argparse.ArgumentParser(add_help=False) shared.add_argument( "-o", "--output", - default="id_ed25519", + default=str(Path.home() / ".ssh" / "id_ed25519"), metavar="PATH", - help="output path for the private key (default: id_ed25519)", + help="output path for the private key (default: ~/.ssh/id_ed25519)", ) shared.add_argument( "-C", "--comment",