Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
moodle_rebase10.1.2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Blinov
moodle_rebase10.1.2
Commits
9c3acd8a
Commit
9c3acd8a
authored
Nov 16, 2011
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up ssh-key generation.
parent
22127d38
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
slapos/recipe/sshkeys_authority.py
slapos/recipe/sshkeys_authority.py
+12
-3
No files found.
slapos/recipe/sshkeys_authority.py
View file @
9c3acd8a
...
...
@@ -28,6 +28,7 @@ import json
import
hashlib
import
os
import
subprocess
import
re
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe.inotify
import
subfiles
...
...
@@ -51,6 +52,8 @@ def sshkeys_authority(args):
break
if
not
os
.
path
.
exists
(
private_key
):
if
os
.
path
.
exists
(
public_key
):
os
.
unlink
(
public_key
)
keygen_cmd
=
[
keygen_binary
,
'-t'
,
key_type
,
'-f'
,
private_key
,
'-s'
,
size
]
# If the keygeneration return an non-zero status, it means there's a
...
...
@@ -72,9 +75,15 @@ def sshkeys_authority(args):
if
keygen
.
wait
()
!=
0
:
raise
subprocess
.
CalledProcessError
(
"%r returned a non-zero status"
%
\
' '
.
join
(
keygen_cmd
))
# Line : "Public key portion is :"
keygen
.
stdout
.
readline
()
public_key_value
=
keygen
.
stdout
.
readline
().
strip
()
public_key_value
=
''
for
line
in
keygen
.
stdout
:
# Perl programming !
# Don't worry, just regex to detect the ssh public key line
matchresult
=
re
.
match
(
r'ssh-.*?=+'
,
line
)
if
matchresult
:
public_key_value
=
matchresult
.
group
(
0
)
break
with
open
(
public_key
,
'w'
)
as
public_key_file
:
public_key_file
.
write
(
public_key_value
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment