MCPcopy Index your code
hub / github.com/prompt-toolkit/ptpython / ensure_key

Function ensure_key

examples/ssh-and-telnet-embed.py:25–30  ·  view source on GitHub ↗
(filename: str = "ssh_host_key")

Source from the content-addressed store, hash-verified

23
24
25def ensure_key(filename: str = "ssh_host_key") -> str:
26 path = pathlib.Path(filename)
27 if not path.exists():
28 rsa_key = asyncssh.generate_private_key("ssh-rsa")
29 path.write_bytes(rsa_key.export_private_key())
30 return str(path)
31
32
33async def interact(connection: PromptToolkitSSHSession | TelnetConnection) -> None:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected