Default key output to ~/.ssh/ and create the directory if needed
This commit is contained in:
@@ -53,6 +53,7 @@ def save_keypair(
|
|||||||
|
|
||||||
pub_path = path.with_suffix("").parent / (path.name + ".pub")
|
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.write_bytes(private_bytes)
|
||||||
path.chmod(0o600)
|
path.chmod(0o600)
|
||||||
pub_path.write_bytes(public_bytes + b"\n")
|
pub_path.write_bytes(public_bytes + b"\n")
|
||||||
@@ -145,9 +146,9 @@ def build_parser() -> argparse.ArgumentParser:
|
|||||||
shared = argparse.ArgumentParser(add_help=False)
|
shared = argparse.ArgumentParser(add_help=False)
|
||||||
shared.add_argument(
|
shared.add_argument(
|
||||||
"-o", "--output",
|
"-o", "--output",
|
||||||
default="id_ed25519",
|
default=str(Path.home() / ".ssh" / "id_ed25519"),
|
||||||
metavar="PATH",
|
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(
|
shared.add_argument(
|
||||||
"-C", "--comment",
|
"-C", "--comment",
|
||||||
|
|||||||
Reference in New Issue
Block a user