Changing the default SSH port on the TorizonCore image

Dear community/support

I would like to change the default port for SSH from 22 to some other number. As far as I know this should be doable by editing /etc/ssh/sshd_config and adding the line: Port xxxx, and by restarting the service. For some reason this does not work, and when I try to ssh from my PC to Verdin SOM it still uses the default port 22.
I’m using a customized TorizonCore image based on: torizon-core-docker-rt-verdin-imx8mp-Tezi_6.3.0-devel-202305+build.7.tar.
I’m wondering why these changes are not applied and how to do it properly on TorizonCore? Any help on this issue is appreciated.

Best regards,


Hi @Marin ,

I did some research and apparently for sshd.socket, which is what TorizonCore uses currently, you can change the port by doing the steps below on the module:

  • Create a new directory in /etc/systemd/system/:
torizon@verdin-imx8mp-14777535:~$ sudo mkdir -p /etc/systemd/system/sshd.socket.d/
  • Inside sshd.socket.d/ create a new file addresses.conf with this content:
ListenStream=<new port number>

As an example, I’ll use port 2522:

torizon@verdin-imx8mp-14777535:~$ cat /etc/systemd/system/sshd.socket.d/addresses.conf  
  • Restart the socket to apply the changes:
torizon@verdin-imx8mp-14777535:~$ sudo systemctl daemon-reload
torizon@verdin-imx8mp-14777535:~$ sudo systemctl restart sshd.socket
  • SSH should be accepting connections on the new port and refusing the ones on port 22:
torizon@verdin-imx8mp-14777535:~$ systemctl status sshd.socket
* sshd.socket
     Loaded: loaded (/usr/lib/systemd/system/sshd.socket; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/sshd.socket.d
     Active: active (listening) since Tue 2023-06-27 14:07:16 UTC; 2min 6s ago
      Until: Tue 2023-06-27 14:07:16 UTC; 2min 6s ago
     Listen: [::]:2522 (Stream)
   Accepted: 6; Connected: 0;
    Process: 2286 ExecStartPre=/usr/bin/mkdir -p /var/run/sshd (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 4073)
     Memory: 8.0K
     CGroup: /system.slice/sshd.socket

Jun 27 14:07:16 verdin-imx8mp-14777535 systemd[1]: Starting sshd.socket...
Jun 27 14:07:16 verdin-imx8mp-14777535 systemd[1]: Listening on sshd.socket.

For more details these are the references I’ve used:

See if this solves your issue.

Best regards,
Lucas Akira

Hi @lucas_a.tx

Thank you for your reply, this solution worked for me.

Best regards,

Glad I was able to help!

Best regards,
Lucas Akira