1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_sshd.git synced 2024-08-16 11:59:49 +02:00
ansible_role_sshd/README.md

100 lines
5.3 KiB
Markdown
Raw Normal View History

[![Ansible Galaxy](https://raw.githubusercontent.com/roles-ansible/ansible_role_sshd/main/.github/galaxy.svg?sanitize=true)](https://galaxy.ansible.com/do1jlr/sshd) [![MIT License](https://raw.githubusercontent.com/roles-ansible/ansible_role_sshd/main/.github/license.svg?sanitize=true)](https://github.com/roles-ansible/ansible_role_sshd/blob/main/LICENSE)
2021-03-13 23:54:41 +01:00
OpenSSH Server
==============
2021-03-13 23:12:49 +01:00
Ansible role to configure the OpenSSH Server ``SSHD``.
The main goal of this role is to manage the sshd.conf file. And some additional parts like deploying the defined ssh host keys at the configured path.
Pro Tipp
----------------
Use Eliptic cureve cryptografie for your ssh keys:
2018-11-12 21:37:43 +01:00
```bash
ssh-keygen -t ed25519
```
2021-04-11 17:23:02 +02:00
*The default values of this role will only allow ed25519 keys. But you can change that obviously if you like.*
2021-09-19 02:47:26 +02:00
intended use
2019-11-14 10:36:18 +01:00
---------------
2021-09-19 02:47:26 +02:00
This role is designed to manage linux hosts with the following roles. This role here basically only focuses on a good configuration of sshd and can define which users are allowd to use connect via ssh and which ssh key types are allowd.
Other roles distribute ssh public keys, creating users and configure sudo permission, roll out dotfiles or install a number of useful packages.
2019-11-14 10:36:18 +01:00
2021-09-19 02:47:26 +02:00
A list of suggested roles to manage your linux host:
- [do1jlr.base](https://github.com/roles-ansible/ansible_role_base.git) *install some useful packages*
- [do1jlr.users](https://github.com/roles-ansible/ansible_role_users.git) *create user and manage sudoers*
- [do1jlr.auth](https://github.com/chaos-bodensee/role-ssh_authorized_keys.git) *deploy ssh pubkeys*
- [do1jlr.sshd](https://github.com/roles-ansible/ansible_role_sshd.git) *(this one)*
- [do1jlr.dotfiles](https://github.com/roles-ansible/ansible_role_dotfiles) *deploy some fancy dotfiles*
Good to know:
---------------
The listed roles use the same variables to create accounts, admins and so on. But the roles have to run in the correct order to work properly.
For example you can't deploy a ssh public key for a user that is not created.
2019-05-15 12:37:25 +02:00
Some Variables explained
------------------------------
**Remember:** Have a look into ``defaults/main.yml`` for all possible variables.
2021-03-13 23:03:31 +01:00
+ **SSH Port**<br/>
2021-03-13 23:01:11 +01:00
The OpenSSH Port is defined with the variable ``sshd__port: 22``. Change it if you wish.
2019-05-15 12:37:25 +02:00
2021-03-13 23:03:31 +01:00
+ **Allowed Users and Groups**<br/>
The default users that are allowd to login come from the ``users: {}`` list.<br/>
The same ``users: {}`` variable is used in the other recomended ssh roles.<br/>
2021-03-13 23:01:11 +01:00
A example to allow the login for the users and groups called ``l3d`` and ``ottojo`` are:
```
2018-11-12 21:37:43 +01:00
users:
l3d:
- l3d
ottojo:
- ottojo@uni
- ottojo@home
```
2021-03-13 23:01:11 +01:00
2021-03-13 23:03:31 +01:00
+ **SSH Login via Passwort**<br/>
2021-03-13 23:01:11 +01:00
The SSH Passwort auth is set to false via ``sshd__password_authentication: false``. This won't allow you to use your passwort to login via SSH.
2021-03-13 23:03:31 +01:00
+ **Manage SSH Key Types**<br/>
2021-03-13 23:01:11 +01:00
By default this role configure which ssh key types are allowed to login. If you don't want to define that change the ``sshd__manage_key_types: true`` variable.
2021-03-13 23:03:31 +01:00
+ **Define allowed ssh key types**<br/>
The allowed SSH Key Types are defined with this list. Some of them are commented out.<br/>
2021-03-13 23:01:11 +01:00
Please not that by defualt only ``ed25519`` keys are allowed. Keep that in mind if you are using a rsa key.
```
sshd__key_types:
- 'ed25519'
# - 'rsa'
# - 'ecdsa'
# - 'dsa' # (do not use!)
```
2021-03-13 23:03:31 +01:00
+ **Advanced SSH Algorithm Settings**<br/>
2021-03-14 00:01:09 +01:00
You can define the used Key and Kex Algorithm here to. For the default values and some examples for the variables ``sshd__key_algorithmus`` and ``sshd__kex_algorithmus`` have a look into ``defaults/main.yml``.
You can disable it by setting ``sshd__manage_key_algorithmus`` and ``sshd__manage_kex_algorithmus`` to ``false``.
2019-05-15 12:37:25 +02:00
2021-03-13 23:03:31 +01:00
+ **force new SSH Features**<br/>
2021-03-13 23:01:11 +01:00
If you know that you use a ssh version ``>8`` you can optionally define it with ``true/false`` with the ``sshd__version_is_above_eight`` variable.
2019-05-15 12:37:25 +02:00
Files
-----
2021-03-13 23:01:11 +01:00
The main task of this role is to configure the ``sshd.conf`` file.
2019-05-15 12:37:25 +02:00
References
----------
* [Secure Secure Shell](https://stribika.github.io/2015/01/04/secure-secure-shell.html)
2021-03-13 23:08:03 +01:00
Testing
--------
This role is tested with some linting tests. Sadly I don't know how to run this role in a docker container because systemd is involved... If you have ideas how to improve testing please dend me a message, open a issue or Pull Request.
If you want to find out more about our tests, please have a look at the github marketplace.
| test status | Github Marketplace |
| :--------- | :---------------- |
| [![Galaxy release](https://github.com/roles-ansible/ansible_role_sshd/actions/workflows/galaxy.yml/badge.svg)](https://github.com/roles-ansible/ansible_role_sshd/actions/workflows/galaxy.yml) | [publish-ansible-role-to-galaxy](https://github.com/marketplace/actions/publish-ansible-role-to-galaxy) |
| [![Yamllint GitHub Actions](https://github.com/roles-ansible/ansible_role_sshd/actions/workflows/yamllint.yaml/badge.svg)](https://github.com/roles-ansible/ansible_role_sshd/actions/workflows/yamllint.yaml) | [yamllint-github-action](https://github.com/marketplace/actions/yamllint-github-action) |
| [![Ansible Lint check](https://github.com/roles-ansible/ansible_role_sshd/actions/workflows/ansible-linting-check.yml/badge.svg)](https://github.com/roles-ansible/ansible_role_sshd/actions/workflows/ansible-linting-check.yml) | [ansible-lint action](https://github.com/marketplace/actions/ansible-lint)