Skip to content
This repository was archived by the owner on Dec 16, 2024. It is now read-only.

Manage sshd_config file #725

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ matrix:
- SALT_NODE_ID=servo-mac1
- SALT_FROM_SCRATCH=true
os: osx
osx_image: xcode8.3
osx_image: xcode8
- env:
- SALT_NODE_ID=servo-mac2
- SALT_FROM_SCRATCH=true
os: osx
osx_image: xcode6.4
- env:
- SALT_NODE_ID=servo-linux1
- SALT_FROM_SCRATCH=true
Expand All @@ -49,7 +54,12 @@ matrix:
- SALT_NODE_ID=servo-mac1
- SALT_FROM_SCRATCH=false
os: osx
osx_image: xcode8.3
osx_image: xcode8
- env:
- SALT_NODE_ID=servo-mac2
- SALT_FROM_SCRATCH=false
os: osx
osx_image: xcode6.4
- env:
- SALT_NODE_ID=servo-linux1
- SALT_FROM_SCRATCH=false
Expand Down
1 change: 1 addition & 0 deletions .travis/dispatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ else
./test.py sls.servo-build-dependencies.android
fi

./test.py sls.admin
# Salt doesn't support timezone.system on OSX
# See https://github.com/saltstack/salt/issues/31345
if [[ ! "${SALT_NODE_ID}" =~ servo-mac.* ]]; then
Expand Down
25 changes: 25 additions & 0 deletions admin/files/sshd_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
HostKey /etc/ssh/ssh_host_ed25519_key
KexAlgorithms [email protected]
Ciphers [email protected]

# Only pubkey authentication is enabled, i.e. password logins are disabled
PasswordAuthentication no
ChallengeResponseAuthentication no
PubkeyAuthentication yes
AuthenticationMethods publickey
# TODO: Disable root login after creating per-user accounts
PermitRootLogin yes

MaxAuthTries 2
LoginGraceTime 1m

{% if grains['kernel'] == 'Linux' %}
UsePAM yes
# PAM does this
PrintMotd no
{% endif %}

UsePrivilegeSeparation sandbox
# LogLevel VERBOSE logs user's key fingerprint on login.
# Needed to have a clear audit track of which key was using to log in.
LogLevel VERBOSE
23 changes: 22 additions & 1 deletion admin/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ admin-packages:
- tmux
- mosh
{% if grains['os'] != 'MacOS' %}
- screen # Installed by default on OS X
- openssh-server # Use default macOS version, not Homebrew's
- screen # Installed by default on macOS
{% endif %}

{% if grains['os'] != 'MacOS' and grains.get('virtual_subtype', '') != 'Docker' %}
Expand All @@ -22,6 +23,15 @@ UTC:
- mode: 644
- source: salt://{{ tpldir }}/files/hosts

sshd_config:
file.managed:
- name: /etc/ssh/sshd_config
- user: {{ root.user }}
- group: {{ root.group }}
- mode: 644
- template: jinja
- source: salt://{{ tpldir }}/files/sshd_config

sshkeys-dir:
file.directory:
- name: {{ root.home }}/.ssh
Expand All @@ -41,3 +51,14 @@ sshkeys:
{% endfor %}
- require:
- file: sshkeys-dir

{% if grains['os'] != 'MacOS' %}
sshd:
service.running:
- name: ssh
- enable: True
- require:
- file: sshkeys
- watch:
- file: sshd_config
{% endif %}
Empty file added tests/sls/admin/__init__.py
Empty file.
20 changes: 20 additions & 0 deletions tests/sls/admin/valid_sshd_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import subprocess

from tests.util import Failure, Success


def run():
proc = subprocess.Popen(
['sshd', '-T', '-f', '/etc/ssh/sshd_config'],
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
universal_newlines=True
)
_, stderr = proc.communicate()

if proc.returncode != 0:
return Failure(
'Invalid sshd_config file:', stderr
)

return Success('SSHD config file is valid')