]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
openvpn/sepia/new-client: save a tarball of secret and secret.hash 762/head
authorDan Mick <dan.mick@redhat.com>
Wed, 18 Dec 2024 21:48:54 +0000 (13:48 -0800)
committerDan Mick <dan.mick@redhat.com>
Wed, 18 Dec 2024 21:50:13 +0000 (13:50 -0800)
Also, explain a little bit more about what new-client has done.
hopefully this helps users understand/keep track of their secrets,
and hopefully this streamlines diagnosing when things go wrong

Signed-off-by: Dan Mick <dan.mick@redhat.com>
tools/openvpn/sepia/new-client

index 9a48188051d2b3d5a43fab271e8359c8bf15e97a..c3181a5c003b7ace98ceef08003653c17896f49c 100755 (executable)
 # sudo service openvpn start sepia
 
 import base64
+import datetime
 import hashlib
 import os
 import re
 import sys
+import tarfile
 
 path = os.path.dirname(sys.argv[0])
 os.chdir(path)
@@ -63,3 +65,18 @@ sys.stdout.write("{user} {salt} {hashed}\n\n".format(
     salt=salt.decode('utf-8'),
     hashed=hashed,
 ))
+
+with open('secret.hash', 'w') as f:
+    f.write(f"{user} {salt.decode('utf-8')} {hashed}")
+
+datestr = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
+tarfilename = f'secrets.{datestr}.tar.gz'
+tarfile = tarfile.open(tarfilename, 'w:gz')
+for f in ['secret', 'secret.hash']:
+    tarfile.add(f)
+tarfile.close()
+
+sys.stdout.write(f"""
+The secret file (private to you) and secret.hash (the above hashed secret
+information, to be placed on the OpenVPN server) are a matched pair.
+They've been placed into {tarfilename} for safekeeping.""")