Merge pull request #8 from carlosperello/master

Allow to manage ssh certificates from pillar definitions
This commit is contained in:
Joseph Hall 2014-02-09 17:19:20 -07:00
commit 54b99b5615
4 changed files with 72 additions and 10 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2013 Salt Stack Formulas Copyright (c) 2013-2014 Salt Stack Formulas
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View File

@ -18,6 +18,21 @@ Available states
Installs the ``openssh`` server package and service. Installs the ``openssh`` server package and service.
``openssh.auth``
-----------
Manages SSH certificates for users.
``openssh.banner``
------------------
Installs a banner that users see when SSH-ing in.
``openssh.client``
------------------
Installs the openssh client package.
``openssh.config`` ``openssh.config``
------------------ ------------------
@ -26,12 +41,3 @@ Installs the ssh daemon configuration file included in this formula
by values from pillar. ``pillar.example`` results in the generation by values from pillar. ``pillar.example`` results in the generation
of the default ``sshd_config`` file on Debian Wheezy. of the default ``sshd_config`` file on Debian Wheezy.
``openssh.client``
------------------
Installs the openssh client package.
``openssh.banner``
------------------
Installs a banner that users see when SSH-ing in.

43
openssh/auth.sls Normal file
View File

@ -0,0 +1,43 @@
include:
- openssh
{% from "openssh/map.jinja" import openssh with context %}
{% set openssh_pillar = pillar.get('openssh', {}) %}
{% set auth = openssh_pillar.get('auth', {}) %}
{% for user,keys in auth.items() -%}
{% for key in keys -%}
{% if 'present' in key and key['present'] %}
{{ key['name'] }}:
ssh_auth.present:
- user: {{ user }}
{% if 'source' in key %}
- source: {{ key['source'] }}
{% else %}
{% if 'enc' in key %}
- enc: {{ key['enc'] }}
{% endif %}
{% if 'comment' in key %}
- comment: {{ key['comment'] }}
{% endif %}
{% if 'options' in key %}
- options: {{ key['options'] }}
{% endif %}
{% endif %}
- require:
- service: {{ openssh.service }}
{% else %}
{{ key['name'] }}:
ssh_auth.absent:
- user: {{ user }}
{% if 'enc' in key %}
- enc: {{ key['enc'] }}
{% endif %}
{% if 'comment' in key %}
- comment: {{ key['comment'] }}
{% endif %}
{% if 'options' in key %}
- options: {{ key['options'] }}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}

View File

@ -28,3 +28,16 @@ sshd_config:
AcceptEnv: "LANG LC_*" AcceptEnv: "LANG LC_*"
Subsystem: "sftp /usr/lib/openssh/sftp-server" Subsystem: "sftp /usr/lib/openssh/sftp-server"
UsePAM: yes UsePAM: yes
openssh:
auth:
joe:
- name: JOE_VALID_SSH_PUBLIC_KEY
present: True
enc: ssh-rsa
comment: main key
- name: JOE_NON_VALID_SSH_PUBLIC_KEY
present: False
enc: ssh-rsa
comment: obsolete key - removed