# \[doc\] Modify the SSH port / Modifier le port SSH

**URL:** <https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917>\
**Category:** Support & doc\
**Tags:** french\
**Created:** [May 21, 2021, 8:44am UTC](https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917 "2021-05-21T08:44:29Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![noolang](https://forum.yunohost.org/user_avatar/forum.yunohost.org/noolang/32/5739_2.png) [@noolang](https://forum.yunohost.org/u/noolang)\
**Post date:** [May 21, 2021, 8:44am UTC](https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917/1 "2021-05-21T08:44:30Z")

</div>

Hello,

The [security page](https://yunohost.org/en/administrate/overview/security) of the admin guide provides explanations on how to change the SSH port. I found (too late — I already followed the guide…) that there is a setting (`security.ssh.port`) that seems to do the job when changed.  
Is it _the_ new way of doing that?

Thanks

* * *

La [page Sécurité](https://yunohost.org/fr/security) du guide d’administration explique comment changer le port SSH. J’ai découvert (trop tard — j’avais déjà suivi la procédure manuelle) qu’il y a un _setting_ (`security.ssh.port`) qui semble faire le boulot automatiquement…  
Est-ce _la_ nouvelle méthode à suivre ?

Merci

---

<div class="post-metadata">

**Author:** ![tituspijean](https://forum.yunohost.org/user_avatar/forum.yunohost.org/tituspijean/32/3584_2.png) [@tituspijean](https://forum.yunohost.org/u/tituspijean)\
**Post date:** [May 21, 2021, 8:54am UTC](https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917/2 "2021-05-21T08:54:37Z")

</div>

Yes it is! I think we forgot to update the documentation about it.

---

<div class="post-metadata">

**Author:** ![noolang](https://forum.yunohost.org/user_avatar/forum.yunohost.org/noolang/32/5739_2.png) [@noolang](https://forum.yunohost.org/u/noolang)\
**Post date:** [May 21, 2021, 9:10am UTC](https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917/3 "2021-05-21T09:10:24Z")

</div>

Note that it must be **done first** , before any other changes to the `/etc/ssh/sshd_config` file (otherwise no modifications will be done to the file by `yunohost settings`)

---

<div class="post-metadata">

**Author:** ![tituspijean](https://forum.yunohost.org/user_avatar/forum.yunohost.org/tituspijean/32/3584_2.png) [@tituspijean](https://forum.yunohost.org/u/tituspijean)\
**Post date:** [May 21, 2021, 10:14am UTC](https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917/4 "2021-05-21T10:14:32Z")

</div>

Done in [Update security.md to use ssh port setting by tituspijean · Pull Request #1683 · YunoHost/doc · GitHub](https://github.com/YunoHost/doc/pull/1683).

---

<div class="post-metadata">

**Author:** ![noolang](https://forum.yunohost.org/user_avatar/forum.yunohost.org/noolang/32/5739_2.png) [@noolang](https://forum.yunohost.org/u/noolang)\
**Post date:** [May 21, 2021, 11:20am UTC](https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917/5 "2021-05-21T11:20:22Z")

</div>

@tituspijean Dans `yunohost settings` la valeur se modifie avec `-v` (et non pas `-p` comme pour la commande SSH)…

Et pour `security.fr.md`, le texte est aussi en anglais (copier/coller trop rapide ?)

Et je pense qu’il y a une espace en trop à la fin de ` **For the next SSH connections** `, ce qui empêche de mettre en gras (en tout cas, c’est comme ça que GH l’[affiche](https://github.com/YunoHost/doc/blob/624c75e3f3471c8a9e634aca04eee6bfbf9041e2/pages/01.administrate/06.overview/12.security/security.md)).

---

<div class="post-metadata">

**Author:** ![tituspijean](https://forum.yunohost.org/user_avatar/forum.yunohost.org/tituspijean/32/3584_2.png) [@tituspijean](https://forum.yunohost.org/u/tituspijean)\
**Post date:** [May 21, 2021, 1:49pm UTC](https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917/6 "2021-05-21T13:49:27Z")

</div>

Plutôt une volonté de faire vite (et donc involontairement mal) pendant la pause déjeuner. C’est corrigé.

---

<div class="post-metadata">

**Author:** ![hermann-san](https://forum.yunohost.org/user_avatar/forum.yunohost.org/hermann-san/32/2639_2.png) [@hermann-san](https://forum.yunohost.org/u/hermann-san)\
**Post date:** [March 24, 2022, 10:35pm UTC](https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917/7 "2022-03-24T22:35:52Z")

</div>

If the port has been modified, then also this port needs to be used with SFTP. It took me a while to figure this out because I was not aware (or forgot) that SFTP is using SSH.

I would find it useful to mention this in the doc’s. What do you think?

> **[Exchange files with your server using a graphical interface | Yunohost...](https://yunohost.org/en/filezilla)**
>
> Yunohost Documentation

I would mention it in Step 2 of Filezilla config.

---

<div class="post-metadata">

**Author:** ![noolang](https://forum.yunohost.org/user_avatar/forum.yunohost.org/noolang/32/5739_2.png) [@noolang](https://forum.yunohost.org/u/noolang)\
**Post date:** [March 25, 2022, 10:19am UTC](https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917/8 "2022-03-25T10:19:23Z")

</div>

You’re right — the S of SFTP doesn’t mean the same thing than the S of HTTPS! 😄  
It won’t hurt to remind this on the doc 👍

---

<div class="post-metadata">

**Author:** ![petesim](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/p/f9ae1b/32.png) [@petesim](https://forum.yunohost.org/u/petesim)\
**Post date:** [September 10, 2022, 12:49pm UTC](https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917/9 "2022-09-10T12:49:58Z")

</div>

Does the command `sudo yunohost settings set security.ssh.port -v <new_ssh_port_number>` from [https://yunohost.org/oc/security#modify-the-ssh-port](https://yunohost.org/oc/security#modify-the-ssh-port) _adds_ a new port, or _replace_ current? Is it possible to _add_ new port keeping default `22` active?

Sorry if this is in man pages, `help` doesn’t work when restoring a new instance from backup. =((

---

<div class="post-metadata">

**Author:** ![noolang](https://forum.yunohost.org/user_avatar/forum.yunohost.org/noolang/32/5739_2.png) [@noolang](https://forum.yunohost.org/u/noolang)\
**Post date:** [September 13, 2022, 7:42am UTC](https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917/10 "2022-09-13T07:42:53Z")

</div>

This command changes the value inside the variable `security.ssh.port`; and this is a single integer, not an array. So, this replaces current port.

I guess you have a good reason to need 2 ports… but this sounds a bit strange.

---

<div class="post-metadata">

**Author:** ![noolang](https://forum.yunohost.org/user_avatar/forum.yunohost.org/noolang/32/5739_2.png) [@noolang](https://forum.yunohost.org/u/noolang)\
**Post date:** [September 13, 2022, 7:55am UTC](https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917/11 "2022-09-13T07:55:27Z")

</div>

As a follow-up to my previous answer…

The man page for `sshd_config` says:

> **Port** Specifies the port number that sshd(8) listens on.  
> The default is 22. Multiple options of this are permitted.

Your first option is then to directly modify `/etc/sshd_config`. But you’ll get a warning by YNH.

So a better option is to create a script to let YNH do it for you: [Share your "hooks" to apply custom configurations- Partagez vos "hooks" pour appliquer des configurations personnelles](https://forum.yunohost.org/t/share-your-hooks-to-apply-custom-configurations-partagez-vos-hooks-pour-appliquer-des-configurations-personnelles/17235)

I didn’t try, but you can search for “Port 22” and replace it by 2 lines (use `\n` I guess).

---

<div class="post-metadata">

**Author:** ![petesim](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/p/f9ae1b/32.png) [@petesim](https://forum.yunohost.org/u/petesim)\
**Post date:** [September 13, 2022, 10:19am UTC](https://forum.yunohost.org/t/doc-modify-the-ssh-port-modifier-le-port-ssh/15917/12 "2022-09-13T10:19:30Z")

</div>

> [@noolang](#):
>
> I guess you have a good reason to need 2 ports… but this sounds a bit strange.

No, it’s just to understand how this works… To know if the previous one is available after command execution. And to know what to do after another migration between VPS.

Thank you!
