Can't change SSH port

What type of hardware are you using: Virtual machine
What YunoHost version are you running: 12.1.36 stable
How are you able to access your server: The webadmin
SSH

Describe your issue

Bonjour,

PVE 9.1.2
LXC Yunohost 12.1.36 stable - installé via Proxmox VE Helper-Scripts

Bonjour, j’essaye de changer le port SSH par defaut 22 par un autre (22222 par exemple).
Ca ne fonctionne pas : lorsque je tape la commande yunohost specifique tout semble bien se passer mais le port ne change pas…

Auriez-vous une idée ? je me demande si proxmox n’interfere pas dans cette configuration mais je ne trouve rien de ce coté non plus.

Merci !

Share relevant logs or error messages

sushi@miniyuno:~$ cat /etc/ssh/sshd_config | grep “Port”
Port 22
sushi@miniyuno:~$ sudo yunohost settings set security.ssh.ssh_port -v 22222 --debug
21   DEBUG   acquiring lock…
27   DEBUG   lock has been acquired
290  DEBUG   loading python module yunohost.settings took 0.262s
290  DEBUG   processing action ‘yunohost.settings.set’
291  DEBUG   Import and parse pre-answered options
312  DEBUG   initializing root ldap interface
313  DEBUG   Ask unanswered question and prevalidate data

========================================

Security
========================================

SSH

1331 INFO    Saving the new configuration…
1333 SUCCESS Config updated as expected
1334 DEBUG   To view the log of the operation ‘Apply settings’, use the command ‘yunohost log show 20251215-194249-settings_set’
1336 DEBUG   action executed in 1.046s
1336 DEBUG   lock has been released
sushi@miniyuno:~$ sudo yunohost settings get security.ssh.ssh_port --debug
267  DEBUG   loading python module yunohost.settings took 0.247s
268  DEBUG   processing action ‘yunohost.settings.get’
289  DEBUG   initializing root ldap interface
290  DEBUG   action executed in 0.022s
22222
sushi@miniyuno:~$ cat /etc/ssh/sshd_config | grep “Port”
Port 22
sushi@miniyuno:~$ sudo systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; disabled; preset: enabled)
Active: active (running) since Thu 2025-12-11 19:04:21 CET; 4 days ago
TriggeredBy: ● ssh.socket
Docs: man:sshd(8)
man:sshd_config(5)
Process: 5322 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 5324 (sshd)
Tasks: 1 (limit: 35863)
Memory: 10.0M
CPU: 2min 28.650s
CGroup: /system.slice/ssh.service
└─5324 “sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups”

La commande ne semble pas aller à son terme et le pare-feu devrait être rechargé.
Peux-tu lancer

sudo yunohost regen-conf --dry-run --with-diff

?

tu veux dire sudo yunohost tools regen-conf ssh --dry-run --with-diff ?

ca me donne :

sushi@miniyuno:~$ sudo yunohost tools regen-conf ssh --dry-run --with-diff
Warning: The configuration file ‘/etc/ssh/sshd_config’ has been manually modified and will not be updated
ssh:
applied:
pending:
/etc/ssh/sshd_config:
diff: @@ -4,7 +4,7 @@
Protocol 2

PLEASE: if you wish to change the ssh port properly in YunoHost, use this command:

yunohost settings set security.ssh.ssh_port -v 

-Port 22
+Port 22222

ListenAddress ::
ListenAddress 0.0.0.0
@@ -107,3 +107,4 @@

If the server is a VPS, it’s expected that the owner of the

server has access to a web console through which to log in.

Match Address 192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,169.254.0.0/16,fe80::/10,fd00::/8

PermitRootLogin yes
status: modified
sushi@miniyuno:~$ cat /etc/ssh/sshd_config | grep "Port"
Port 22

Oui. Tu peux le lancer avec --force, cela peut suffire. Il faudrait peut-être aussi voir si cela renvoie qqch pour nftables et fail2ban.

tu veux dire :

sushi@miniyuno:~$ sudo yunohost tools regen-conf ssh --dry-run --with-diff --force
[sudo] password for sushi:
Success! The configuration would have been updated for category ‘ssh’
ssh:
applied:
/etc/ssh/sshd_config:
diff: @@ -4,7 +4,7 @@
Protocol 2

PLEASE: if you wish to change the ssh port properly in YunoHost, use this command:

yunohost settings set security.ssh.ssh_port -v 

-Port 22
+Port 22222

ListenAddress ::
ListenAddress 0.0.0.0
@@ -107,3 +107,4 @@

If the server is a VPS, it’s expected that the owner of the

server has access to a web console through which to log in.

Match Address 192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,169.254.0.0/16,fe80::/10,fd00::/8

PermitRootLogin yes
status: force-updated
pending:
sushi@miniyuno:~$ cat /etc/ssh/sshd_config | grep “Port”
Port 22
sushi@miniyuno:~$ sudo yunohost settings set security.ssh.ssh_port -v 22222 --debug
21   DEBUG   acquiring lock…
27   DEBUG   lock has been acquired
266  DEBUG   loading python module yunohost.settings took 0.238s
266  DEBUG   processing action ‘yunohost.settings.set’
267  DEBUG   Import and parse pre-answered options
288  DEBUG   initializing root ldap interface
289  DEBUG   Ask unanswered question and prevalidate data

========================================

Security
========================================

SSH

1307 INFO    Saving the new configuration…
1309 SUCCESS Config updated as expected
1310 DEBUG   To view the log of the operation ‘Apply settings’, use the command ‘yunohost log show 20251215-223412-settings_set’
1312 DEBUG   action executed in 1.046s
1312 DEBUG   lock has been released
sushi@miniyuno:~$ cat /etc/ssh/sshd_config | grep “Port”
Port 22
sushi@miniyuno:~$

Simplement sudo yunohost tools regen-conf ssh --force

cela me donne :

sushi@miniyuno:~$ sudo yunohost tools regen-conf ssh --force
Success! Configuration updated for ‘ssh’
ssh:
applied:
/etc/ssh/sshd_config:
status: force-updated
pending:
sushi@miniyuno:~$ cat /etc/ssh/sshd_config | grep “Port”
Port 22222
sushi@miniyuno:~$

Mais dans mon terminal j’accede toujours via le port 22 en SSH

Car le pare-feu n’a pas été rechargé. yunohost firewall reload
Lance sudo yunohost tools regen-conf nftables fail2ban et regarde si cela renvoie qqch.
Essaie aussi systemctl restart yunohost-api, je pense que cela doit recharger -entre autres- le parefeu.

Je ne sais pas comment le recharger ! :grimacing:

sudo yunohost firewall reload

merci !

via l’interface web je peux voir qu’aucune regle n’a ete ajoutée pour le port 22222

et j’ai toujours :

ssh: connect to host ``xxx.ynh.fr`` port 22222: Connection refused

alors que (et ca continue à marcher via le port 22):

sushi@miniyuno:~$ cat /etc/ssh/sshd_config | grep “Port”
Port 22222

as-tu essayé :

sudo yunohost tools regen-conf nftables fail2ban ne donne aucun message

sudo systemctl restart yunohost-api non plus

la regle du pare-feu 22222 a bien ete créée mais la connection passe toujours par le port 22 dans mon terminal

Essaie de relancer sudo yunohost settings set security.ssh.ssh_port -v 22222: Tu devrais avoir plusieurs messages SUCCESS

Success! Configuration updated for 'ssh'
Success! Configuration updated for 'fail2ban'
Success! Configuration updated for 'nftables'
Success! Firewall reloaded
Success! Config updated as expected

Malheureusement qu’un seul success ! :sweat_smile:

sushi@miniyuno:~$ sudo yunohost settings set security.ssh.ssh_port -v 22222

========================================

Security
========================================

SSH

Info: Saving the new configuration…
Success! Config updated as expected
sushi@miniyuno:~$ cat /etc/ssh/sshd_config | grep "Port"
Port 22222

Estce que proxmox pourrait interferer dans ces reglages ?

Je ne crois pas, non. Essaie de voir si tu peux changer le port depuis la webadmin.

il est deja sur 22222 la page web des parametres

Ce que je veux dire par là, c’est que tu ne pourras pas savoir si les modifications faites fonctionnent si tu n’essaies pas la commande avec un autre port. Si 22222 est déjà enregistré partout, il est normal que tu n’aies que Success! Config updated as expected

Ok, je comprends. J’ai changé le port via webadmin pour 22022, pas d’erreur en sauvegardant et le pare-feu a correctement créé la regle pour ce port.

voir https://paste.yunohost.org/raw/lenilenuhu

Cependant toujours port 22022: Connection refused et par contre ca passe en 22

J’ai fait un sudo systemctl restart yunohost-api mais ca ne change rien

Oui, là, c’est bizarre car j’imagine que tu as bien 22022 dans /etc/ss/sshd_config?
Est-ce que systemctl restart ssh change qqch ?