Commit b138f9fc authored by Tilman Vatteroth's avatar Tilman Vatteroth 💻

init with UFC sshd role

parents
## General
This role installs and configures an OpenSSH-Server. It uses [Mozilla's Modern Config](https://infosec.mozilla.org/guidelines/openssh.html)
## Variables
- `SSHD_PORT`: The port sshd should listen on. (Default: 22)
- `SSHD_PERMIT_ROOT_LOGIN`: Allow Root-Login (Default: no)
- `SSHD_ALLOW_PUBKEYS`: Allow login with pubkey (Default: yes)
- `SSHD_ALLOW_PASSWORDS`: Allow login with passwords (Default: no)
- `SSHD_PRINT_MOTD`: Print the MotD after login (Default: no)
- `SSHD_AGENT_FORWARDING`: Allow Agent-Forwarding (Default: yes)
- `SSHD_TCP_FORWARDING`: Allow TCP-Forwarding (Default: yes)
- `SSHD_X11_FORWARDING`: Allow X11-Forwarding (Default: yes)
- `SSHD_LISTEN_ADDRESSES`: The addresses sshd should listen on. (Default: 0.0.0.0 and ::)
---
SSHD_PORT: 22
SSHD_PERMIT_ROOT_LOGIN: no
SSHD_ALLOW_PUBKEYS: yes
SSHD_ALLOW_PASSWORDS: no
SSHD_PRINT_MOTD: no
SSHD_AGENT_FORWARDING: no
SSHD_TCP_FORWARDING: no
SSHD_X11_FORWARDING: no
SSHD_LISTEN_ADDRESSES:
- "0.0.0.0"
- "::"
---
- name: start sshd
systemd:
name: sshd
enabled: yes
state: restarted
---
- name: install openssh-server
apt:
name: openssh-server
state: present
notify: start sshd
# Remove every moduli that is unsafer than 3071
- name: remove unsafe moduli
lineinfile:
regexp: '\d* \d \d \d\d\d (([0-9]\d?\d?)|([1-2]\d\d\d)|(30[0-6]\d)|(3070)) \d [0-9A-Z]*'
state: absent
path: /etc/ssh/moduli
- name: copy config
template:
src: sshd_config.conf.j2
dest: /etc/ssh/sshd_config
notify: start sshd
# MANAGED BY ANSIBLE
# EVERY CHANGE WILL BE PURGED
Port {{ SSHD_PORT }}
#AddressFamily any
{% for item in SSHD_LISTEN_ADDRESSES %}
ListenAddress {{ item }}
{% endfor %}
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
#LoginGraceTime 2m
PermitRootLogin {{ 'yes' if SSHD_PERMIT_ROOT_LOGIN else 'no' }}
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
# Authentication
PubkeyAuthentication {{ 'yes' if SSHD_ALLOW_PUBKEYS else 'no' }}
PasswordAuthentication {{ 'yes' if SSHD_ALLOW_PASSWORDS else 'no' }}
PermitEmptyPasswords no
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
AllowAgentForwarding {{ 'yes' if SSHD_AGENT_FORWARDING else 'no' }}
AllowTcpForwarding {{ 'yes' if SSHD_TCP_FORWARDING else 'no' }}
#GatewayPorts no
X11Forwarding {{ 'yes' if SSHD_X11_FORWARDING else 'no' }}
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd {{ 'yes' if SSHD_PRINT_MOTD else 'no' }}
#PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
###### EVERYTHING BELOW IS SUGGESTED BY MOZILLA ######
LogLevel VERBOSE
HostKey /etc/ssh/ssh_host_ed25519_key
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
Subsystem sftp /usr/lib/openssh/sftp-server -f AUTHPRIV -l INFO
UsePrivilegeSeparation sandbox
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment