Skip to content

Commit aab0ee2

Browse files
nethsm: Add move-key command
1 parent 02d924d commit aab0ee2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pynitrokey/cli/nethsm.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,20 @@ def get_key(ctx: Context, key_id: str, public_key: bool) -> None:
641641
print(f"Public key: {key.public_key}")
642642

643643

644+
@nethsm.command()
645+
@click.argument("old-key-id")
646+
@click.argument("new-key-id")
647+
@click.pass_context
648+
def move_key(ctx: Context, old_key_id: str, new_key_id: str) -> None:
649+
"""Move the key pair with the given old key ID to the new key ID (requires NetHSM v3).
650+
651+
This command requires authentication as a user with the Administrator
652+
role."""
653+
with connect(ctx) as nethsm:
654+
nethsm.move_key(old_key_id, new_key_id)
655+
print(f"Key {old_key_id} moved to {new_key_id} on NetHSM {nethsm.host}")
656+
657+
644658
@nethsm.command()
645659
@click.argument("key-id")
646660
@click.pass_context

0 commit comments

Comments
 (0)