From 0706ac59096167c494cb90a7999f7dbdb3a1da9f Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 8 Jan 2018 19:35:39 +0100 Subject: [PATCH] Shorten generated ssh key and add seconds to the name --- hosting/forms.py | 3 +-- hosting/views.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hosting/forms.py b/hosting/forms.py index d1c9d03a..dbb18730 100644 --- a/hosting/forms.py +++ b/hosting/forms.py @@ -15,8 +15,7 @@ logger = logging.getLogger(__name__) def generate_ssh_key_name(): - return 'dcl-generated-key-' + datetime.datetime.now().strftime( - '%m%d%y%H%M') + return 'dcl-gen-key-' + datetime.datetime.now().strftime('%m%d%y%H%M%S') class HostingUserLoginForm(forms.Form): diff --git a/hosting/views.py b/hosting/views.py index 576b3534..8f9f7c31 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -487,7 +487,7 @@ class SSHKeyCreateView(LoginRequiredMixin, FormView): def form_valid(self, form): form.save() - if 'dcl-generated-key-' in form.instance.name: + if 'dcl-gen-key-' in form.instance.name: content = ContentFile(form.cleaned_data.get('private_key')) filename = form.cleaned_data.get( 'name') + '_' + str(uuid.uuid4())[:8] + '_private.pem'