doc/pages/02.administer/45.tutorials/60.security/security.md

106 lines
4.9 KiB
Markdown
Raw Normal View History

2020-11-11 11:47:10 +01:00
---
title: Security
template: docs
taxonomy:
category: docs
routes:
default: '/security'
2020-11-11 11:47:10 +01:00
---
2014-05-13 16:09:43 +02:00
2022-02-01 15:26:58 +01:00
YunoHost has been developed to provide the best security without too much complication. Every protocol used in YunoHost is **encrypted**, only a password's hashes are stored and by default each user is able to access their personal directory only.
2014-05-13 16:09:43 +02:00
Two things remain important to note:
2022-02-01 15:26:58 +01:00
* Installing additional apps can **significantly increase** the number of potential security flaws. Do not hesitate to get information about security flaws **before installing an app**, and try to only install apps which will suit your needs.
2014-05-13 16:09:43 +02:00
2022-02-01 15:26:58 +01:00
* The fact that YunoHost is a well-known and used piece of software increases the chances of an attack. If a flaw is discovered, it could potentially affect all YunoHost instances at once. Keep your system **up-to-date** to remain safe. Updates can be automated by installing the ["Unattended_upgrades" app](https://install-app.yunohost.org/?app=unattended_upgrades).
2014-05-13 16:09:43 +02:00
!!!! If you need advice, do not hesitate to [ask us](/help).
2014-05-13 16:09:43 +02:00
!! [fa=shield /] To discuss security flaws, contact the [YunoHost security team](/security_team).
2014-06-04 21:41:04 +02:00
---
2014-05-13 16:09:43 +02:00
## Improve security
2022-02-01 15:26:58 +01:00
If your YunoHost server is used in a critical production environment, or if you want to improve its safety, you may want to follow these good practices.
2014-05-13 16:09:43 +02:00
2022-02-01 15:26:58 +01:00
! **WARNING:** Following these instructions requires advanced knowledge of system administration.
2014-05-13 16:09:43 +02:00
2021-11-25 23:33:01 +01:00
!!!! **TIP** Never close your current SSH connection before checking that your alterations work. Test your new configuration by opening a new terminal or window. That way, you can undo your alterations if anything goes wrong.
2014-05-13 16:09:43 +02:00
### SSH authentication via key
By default, the SSH authentication uses the administration password. Deactivating this kind of authentication and replacing it by a key mechanism is advised.
2014-05-13 16:09:43 +02:00
**On your client**:
```bash
ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub <username@your_yunohost_server>
2014-05-13 16:09:43 +02:00
```
2022-02-01 15:26:58 +01:00
!!! If you run into permissions issues, set `username` as owner of the dir `~/.ssh` with `chown`. Be careful, for security reasons this directory should be in mode `700`.
!!! If you are on Ubuntu 16.04 you should run `ssh-add` to initialize the SSH agent.
2014-05-13 16:09:43 +02:00
2022-02-01 15:26:58 +01:00
Type your admnistration password and your key will be copied onto your server.
2014-05-13 16:09:43 +02:00
2022-02-01 15:26:58 +01:00
**On your server**, editing the SSH configuration file to deactivate password authentication is handled by a system setting:
2014-05-13 16:09:43 +02:00
```bash
sudo yunohost settings set security.ssh.password_authentication -v no
```
2014-06-04 21:41:04 +02:00
---
### Modify the SSH port
2014-05-13 16:09:43 +02:00
2022-02-01 15:26:58 +01:00
To prevent SSH connection attempts by robots that scan the internet for any server with SSH enabled, you can change the SSH port.
This is handled by a system setting, which takes care of updating the SSH and Fail2Ban configuration.
! If you modify anything in the `/etc/ssh/sshd_config` file, even if only the port, YunoHost will no longer manage this file. For this reason, always use the YunoHost admin tools to make changes to the systems configuration files!
```bash
sudo yunohost settings set security.ssh.port -v <new_ssh_port_number>
```
2022-02-01 15:26:58 +01:00
**For subsequent SSH connections**, you need to add the `-p` option followed by the SSH port number.
2016-01-20 17:04:35 +01:00
**Sample**:
```bash
ssh -p <new_ssh_port_number> admin@<your_yunohost_server>
```
2016-01-20 17:04:35 +01:00
---
### Change cipher compatibility configuration
2022-02-01 15:26:58 +01:00
The default TLS configuration for services tends to offer good compatibility to support old devices. You can tune this policy for specific services like SSH and NGINX. By default, the NGINX configuration follows the [intermediate compatibility recommendation](https://wiki.mozilla.org/Security/Server_Side_TLS#Intermediate_compatibility_.28default.29) from Mozilla. You can choose to switch to the 'modern' configuration which uses more recent security recommendations, but decreases compatibility, which may be an issue for your users and visitors using older devices. More details about compatibility can be found on [this page](https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility).
Changing the compatibility level is not definitive and can be reverted if it doesn't fit with your environment.
**On your server**, change the policy for NGINX
```bash
sudo yunohost settings set security.nginx.compatibility -v modern
```
**On your server**, change the policy for SSH
```bash
sudo yunohost settings set security.ssh.compatibility -v modern
```
### Disable the YunoHost API
2022-12-01 22:39:00 +01:00
YunoHost administration is accessible through an **HTTP API**, served on the 6787 port by default (only on `localhost`).
It can be used to administer a lot of things on your server, so malicious actors can also use it to damage your server.
The best thing to do, if you know how to use the [command-line interface](/commandline), is to deactivate the `yunohost-api` service.
! This will completely disable both YunoHost's API and the web administration panel that relies on it.
2022-12-14 08:06:49 +01:00
! Proceed only if you are comfortable with the command line interface.
2016-01-20 17:04:35 +01:00
```bash
2018-12-11 03:47:36 +01:00
sudo systemctl disable yunohost-api
sudo systemctl stop yunohost-api
```