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
Jean-Paul Smets
slapos
Commits
fc7c0aea
Commit
fc7c0aea
authored
Aug 24, 2016
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pbs/sshkeys_authority: adds support for openssh, and support port in known_hosts file
parent
6ff8f9d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
slapos/recipe/pbs.py
slapos/recipe/pbs.py
+2
-1
slapos/recipe/sshkeys_authority.py
slapos/recipe/sshkeys_authority.py
+14
-4
No files found.
slapos/recipe/pbs.py
View file @
fc7c0aea
...
...
@@ -249,7 +249,8 @@ class Recipe(GenericSlapRecipe, Notify, Callback):
# Create known_hosts file by default.
# In some case, we don't want to create it (case where we share IP mong partitions)
if
not
self
.
isTrueValue
(
self
.
options
.
get
(
'ignore-known-hosts-file'
)):
known_hosts_file
[
parsed_url
.
hostname
]
=
entry
[
'server-key'
]
known_hostname
=
"[%s]:%s"
%
(
parsed_url
.
hostname
,
parsed_url
.
port
)
known_hosts_file
[
known_hostname
]
=
entry
[
'server-key'
].
strip
()
notifier_wrapper_path
=
os
.
path
.
join
(
self
.
options
[
'wrappers-directory'
],
slave_id
)
rdiff_wrapper_path
=
notifier_wrapper_path
+
'_raw'
...
...
slapos/recipe/sshkeys_authority.py
View file @
fc7c0aea
...
...
@@ -33,18 +33,24 @@ import re
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe.inotify
import
subfiles
# This authority only works with dropbear
sshkey generator
# This authority only works with dropbear
or openssh sshkey generators
def
sshkeys_authority
(
args
):
requests_directory
=
args
[
'requests'
]
keygen_binary
=
args
[
'sshkeygen'
]
if
'openssh'
in
keygen_binary
:
authority_type
=
'openssh'
else
:
# Keep dropbear for compatibility
authority_type
=
'dropbear'
for
request_filename
in
subfiles
(
requests_directory
):
with
open
(
request_filename
)
as
request_file
:
request
=
json
.
load
(
request_file
)
key_type
=
request
.
get
(
'type'
,
'rsa'
)
size
=
str
(
request
.
get
(
'size'
,
2048
))
size
=
str
(
request
.
get
(
'size'
,
4096
))
try
:
private_key
=
request
[
'private_key'
]
public_key
=
request
[
'public_key'
]
...
...
@@ -54,8 +60,12 @@ def sshkeys_authority(args):
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
authority_type
==
'openssh'
:
keygen_cmd
=
[
keygen_binary
,
'-N'
,
""
,
'-C'
,
""
,
'-t'
,
key_type
,
'-f'
,
private_key
,
'-b'
,
size
]
else
:
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
# big problem. Let's exit in this case
subprocess
.
check_call
(
keygen_cmd
,
env
=
os
.
environ
.
copy
())
...
...
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