remove ssh.id_ed25519 from facts test
we have moved this to vars now.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
@@ -20,25 +19,3 @@ def is_valid_age_key(secret_key: str) -> bool:
|
||||
return True
|
||||
msg = f"Invalid age key: {secret_key}"
|
||||
raise Error(msg)
|
||||
|
||||
|
||||
def is_valid_ssh_key(secret_key: str, ssh_pub: str) -> bool:
|
||||
# create tempfile and write secret_key to it
|
||||
with tempfile.NamedTemporaryFile() as temp:
|
||||
temp.write(secret_key.encode("utf-8"))
|
||||
temp.flush()
|
||||
# Run the ssh-keygen command with the -y flag to check the key format
|
||||
result = subprocess.run(
|
||||
["ssh-keygen", "-y", "-f", temp.name],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
if result.returncode == 0:
|
||||
if result.stdout != ssh_pub:
|
||||
msg = f"Expected '{ssh_pub}' got '{result.stdout}' for ssh key: {secret_key}"
|
||||
raise Error(msg)
|
||||
return True
|
||||
msg = f"Invalid ssh key: {secret_key}"
|
||||
raise Error(msg)
|
||||
|
||||
Reference in New Issue
Block a user