Add sub-projects

This commit is contained in:
2025-04-16 15:08:51 +02:00
parent 2dbf216d37
commit db538adfdd
22 changed files with 1157 additions and 0 deletions

View File

View File

@ -0,0 +1,39 @@
"""Client code"""
import base64
from typing import TextIO
import click
import asyncio
import asyncssh
from sshecret.crypto import decode_string, load_private_key
# async def request_secret(host: str, port: str, username: str, client_key: str, secretname: str) -> str:
# """Request secret."""
# async with asyncssh.connect(host, port, client_username=username, client_keys=[client_key]) as conn:
# result = await conn.run(secretname, check=True)
# if encoded := result.stdout:
# if isinstance(encoded, str):
# return encoded
# return encoded.decode()
def decrypt_secret(encoded: str, client_key: str) -> str:
"""Decrypt secret."""
private_key = load_private_key(client_key)
return decode_string(encoded, private_key)
@click.command()
@click.argument("keyfile", type=click.Path(exists=True, readable=True, dir_okay=False))
@click.argument("encrypted_input", type=click.File("r"))
def cli_decrypt(keyfile: str, encrypted_input: TextIO) -> None:
"""Decrypt on command line."""
decrypted = decrypt_secret(encrypted_input.read(), keyfile)
click.echo(decrypted)
if __name__ == "__main__":
cli_decrypt()

View File

@ -0,0 +1,16 @@
[project]
name = "sshecret-client"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"asyncssh>=2.20.0",
"click>=8.1.8",
"cryptography>=44.0.2",
"paramiko>=3.5.1",
"sshecret",
]
[tool.uv.sources]
sshecret = { workspace = true }