# Use non-standard port for ssh logins

**URL:** <https://forums.rockylinux.org/t/use-non-standard-port-for-ssh-logins/12154>\
**Category:** Rocky Linux Help & Support\
**Tags:** rocky-linux-9\
**Created:** [December 13, 2023, 9:06pm UTC](https://forums.rockylinux.org/t/use-non-standard-port-for-ssh-logins/12154 "2023-12-13T21:06:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmfwi](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@dmfwi](https://forums.rockylinux.org/u/dmfwi)\
**Post date:** [December 13, 2023, 9:06pm UTC](https://forums.rockylinux.org/t/use-non-standard-port-for-ssh-logins/12154/1 "2023-12-13T21:06:11Z")

</div>

I’d like to use a non-standard port for ssh logins. When I change /etc/sshd\_config so that Port nn is my new port I cannot even restart ssh.

I’ve been around Linux for some time but I have not had occasion to use either the firewall or selinux. So please don’t suggest I change either of these because frankly I don’t know how. I require details.

---

<div class="post-metadata">

**Author:** ![iwalker](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/iwalker/32/2599_2.png) [@iwalker](https://forums.rockylinux.org/u/iwalker)\
**Post date:** [December 13, 2023, 9:16pm UTC](https://forums.rockylinux.org/t/use-non-standard-port-for-ssh-logins/12154/2 "2023-12-13T21:16:05Z")

</div>

Here is an article from google on how to set a different port: [https://computingforgeeks.com/change-ssh-port-centos-rhel-fedora-with-selinux/](https://computingforgeeks.com/change-ssh-port-centos-rhel-fedora-with-selinux/)

It also tells you how to set selinux to use that new port. That is most likely the reason why it failed to restart after being changed. Steps 3 and 4 address selinux and the firewall. Steps 2 and 5 address changing the ssh config and restarting it.

---

<div class="post-metadata">

**Author:** ![jlehtone](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jlehtone](https://forums.rockylinux.org/u/jlehtone)\
**Post date:** [December 13, 2023, 9:42pm UTC](https://forums.rockylinux.org/t/use-non-standard-port-for-ssh-logins/12154/3 "2023-12-13T21:42:40Z")

</div>

> [@iwalker](#):
>
> That is most likely the reason why it failed to restart after being changed.

Indeed. Process starts. Tries to listen on port. SELinux says: “no”. Process could run without listening that port, or die. Sshd does die.

* * *

@dmfwi If you do have Rocky 9, then do not edit `/etc/ssh/sshd_config` – add a new `*.conf` file into `/etc/ssh/sshd_config.d/` and you choices in it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/rockylinux/original/1X/91b7219eec10e30013422e4df76c1d898711a5d5.svg) [@system](https://forums.rockylinux.org/u/system)\
**Post date:** [February 11, 2024, 9:43pm UTC](https://forums.rockylinux.org/t/use-non-standard-port-for-ssh-logins/12154/4 "2024-02-11T21:43:11Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
