Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alain Takoudjou
slapos
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
...
@@ -28,6 +28,7 @@ import json
import
hashlib
import
hashlib
import
os
import
os
import
subprocess
import
subprocess
import
re
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe.inotify
import
subfiles
from
slapos.recipe.librecipe.inotify
import
subfiles
...
@@ -51,6 +52,8 @@ def sshkeys_authority(args):
...
@@ -51,6 +52,8 @@ def sshkeys_authority(args):
break
break
if
not
os
.
path
.
exists
(
private_key
):
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
,
keygen_cmd
=
[
keygen_binary
,
'-t'
,
key_type
,
'-f'
,
private_key
,
'-s'
,
size
]
'-s'
,
size
]
# If the keygeneration return an non-zero status, it means there's a
# If the keygeneration return an non-zero status, it means there's a
...
@@ -72,9 +75,15 @@ def sshkeys_authority(args):
...
@@ -72,9 +75,15 @@ def sshkeys_authority(args):
if
keygen
.
wait
()
!=
0
:
if
keygen
.
wait
()
!=
0
:
raise
subprocess
.
CalledProcessError
(
"%r returned a non-zero status"
%
\
raise
subprocess
.
CalledProcessError
(
"%r returned a non-zero status"
%
\
' '
.
join
(
keygen_cmd
))
' '
.
join
(
keygen_cmd
))
# Line : "Public key portion is :"
public_key_value
=
''
keygen
.
stdout
.
readline
()
for
line
in
keygen
.
stdout
:
public_key_value
=
keygen
.
stdout
.
readline
().
strip
()
# 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
:
with
open
(
public_key
,
'w'
)
as
public_key_file
:
public_key_file
.
write
(
public_key_value
)
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