Update 'backup/generate-config.py'

pull/4/head
drunkendog 2022-12-20 19:27:26 +00:00
parent 566ee37cc1
commit 9979fe0e5c
1 changed files with 4 additions and 0 deletions

View File

@ -14,6 +14,8 @@ s.close()
assert socket.gethostbyname(hostname + ".162536.xyz") == ip_address, "Hostname does not resolve to ip!" assert socket.gethostbyname(hostname + ".162536.xyz") == ip_address, "Hostname does not resolve to ip!"
secret_seed = getpass.getpass("Enter passphrase: ").rstrip() secret_seed = getpass.getpass("Enter passphrase: ").rstrip()
assert getpass.getpass("Confirm passhphrase: ").rstrip() == secret_seed, "Passphrases do not match!"
salted_secret_seed = hostname + secret_seed salted_secret_seed = hostname + secret_seed
salted_hash_value = hashlib.sha512(salted_secret_seed.encode()) salted_hash_value = hashlib.sha512(salted_secret_seed.encode())
@ -22,4 +24,6 @@ with open("/etc/backup.conf", "w") as f:
f.write(f"export BORG_PASSPHRASE='{salted_hash_value.hexdigest()}'\n") f.write(f"export BORG_PASSPHRASE='{salted_hash_value.hexdigest()}'\n")
os.system("ssh-keygen -t rsa -q -f \"$HOME/.ssh/id_rsa\" -N \"\"") os.system("ssh-keygen -t rsa -q -f \"$HOME/.ssh/id_rsa\" -N \"\"")
input(f"Waiting for user creation: press enter when user created - suggested password: {os.system('openssl rand -hex 20')}")
os.system(f"ssh-copy-id {hostname}@{server_hostname}.162536.xyz") os.system(f"ssh-copy-id {hostname}@{server_hostname}.162536.xyz")