diff --git a/roles/ynh_config/README-FR.md b/roles/ynh_config/README-FR.md
index bc959f04487dc2e7862055db3a8f17812c47d2a5..d35a625ef168e44952d99f6cd7b441551981673b 100644
--- a/roles/ynh_config/README-FR.md
+++ b/roles/ynh_config/README-FR.md
@@ -50,6 +50,16 @@ Si des mises à jour sont disponibles, elles sont faites automatiquement. En cas
 
 Pour en savoir plus sur le fonctionnement des mises à jour dans Yunohost vous pouvez vous rendre [ici](https://yunohost.org/fr/update). Le changelog des versions de Yunohost est aussi disponible [ici](https://forum.yunohost.org/tag/ynh_release).
 
+### Modification du port SSH
+
+Parmi les paramètres proposés dans YunoHost, il est possible de modifier le port SSH. Vous devez juste créer la variable `ynh_ssh_port` et le rôle se chargera d'aller récupérer le port SSH et de le modifier si nécessaire. Il va aussi effectuer les changements appropriés pour fail2ban et le firewall interne de YunoHost.
+Si votre instance YunoHost est derrière un firewall applicatif ou propre à votre fournisseur cloud, il faudra également ouvrir le groupe de sécurité approprié.
+
+```yml
+ynh_ssh_port: "812"
+```
+⚠️ Attention, à partir du moment où le port SSH est modifié, la prochaine fois que vous voudrez vous connecter en SSH sur le serveur YunoHost, il faudra renseigner le port SSH utilisé (par exemple `ssh -p 812 username@hostname`). Vous pouvez également externaliser cette configuration vers un fichier de configuration SSH (plus d'infos [ici](https://linuxize.com/post/using-the-ssh-config-file/)).
+
 ## Dépendances
 
 Aucune.
diff --git a/roles/ynh_config/README.md b/roles/ynh_config/README.md
index 829ccc54738c760cc7bba11f226a6dcc2699a1f5..665e70076c54be1485b71e065439d085a68234e6 100644
--- a/roles/ynh_config/README.md
+++ b/roles/ynh_config/README.md
@@ -50,6 +50,17 @@ If available, updates are done automatically. In case of problems following an a
 
 To learn more about how updates work in Yunohost you can go [here](https://yunohost.org/fr/update). The changelog of Yunohost versions is also available [here](https://forum.yunohost.org/tag/ynh_release).
 
+### SSH port modification
+
+Among the settings available in YunoHost, it is possible to change the SSH port. You just have to create the `ynh_ssh_port` variable and the role will retrieve the SSH port and modify it if necessary. It will also perform the adequate modifications regarding fail2ban and the internal firewall of YunoHost.
+In your YunoHost host is behind a firewall, you may consider creating the appropriate security group.
+
+``yml
+ynh_ssh_port: "812"
+```
+
+⚠️ Be careful, from the moment the SSH port is modified, the next time you want to connect to the YunoHost server with SSH, you will have to specify the SSH port to be used (for example `ssh -p 812 username@hostname`). You can also externalize this configuration to an SSH configuration file (more info [here](https://linuxize.com/post/using-the-ssh-config-file/)).
+
 ## Dependencies
 
 None.
diff --git a/roles/ynh_config/tasks/main.yml b/roles/ynh_config/tasks/main.yml
index e9d1561d5dd32519af1171caa01c0c09417d786d..b7f44f33676f736a4b420842320be1a1d7db2a2c 100644
--- a/roles/ynh_config/tasks/main.yml
+++ b/roles/ynh_config/tasks/main.yml
@@ -26,9 +26,27 @@
     - yunohost
     - smtp
 
-- name: Configures Yunohost autoupdate
+- name: Configure Yunohost autoupdate
   ansible.builtin.include_tasks: autoupdate.yml
   when: ynh_autoupdate.scheduled
   tags:
     - yunohost
     - update
+
+- name: Change SSH port
+  block:
+    - name: Get current SSH setting
+      ansible.builtin.command:
+        yunohost settings get security.ssh.port
+      register: _ynh_ssh_current_value
+      changed_when: False
+
+    - name: Set new SSH setting
+      ansible.builtin.command:
+        "yunohost settings set security.ssh.port -v {{ ynh_ssh_port }}"
+      when: _ynh_ssh_current_value != ynh_ssh_port
+      changed_when: False
+  when: ynh_ssh_port
+  tags:
+    - yunohost
+    - ssh