How to change default SSH port on Angstrom

Hello everyone. I found this post, but the command

/etc/init.d/ssh restart
doesn’t work because /etc/inid.d/ssh directory not exists.
How can I fix this?



You cannot fix this.

In all our images we use systemd as the init manager, the command you quote applies to a system using SysV.

To restart a service with systemd use the systemctl command, e.g. for the ssh service:

systemctl restart lxdm.service

As an alternative, simply rebooting the system will also restart all services.

The ssh server is somewhat special as systemd keeps the relevant socket open and will only start the server when someone tries to connect. This is controlled by the sshd.socket and sshd@.service unit files. In such a setup the port setting in /etc/ssh/sshd_config is not evaluated.

So you would have to adapt the socket configuration file and restart the socket to change the port the ssh server can be reached.
Note that one would usually put machine specific configurations in /etc/systemd/system.


root@colibri-imx6:~# cp /lib/systemd/system/sshd.socket /etc/systemd/system/                                                                                                 
root@colibri-imx6:~# vi /etc/systemd/system/sshd.socket
# change the ListenStream=22 to whatever port you need and save the file

root@colibri-imx6:~# systemctl daemon-reload
root@colibri-imx6:~# systemctl restart sshd.socket