Linux Softwares

Can’t change SSH port Armbian 24.5.1 Bookworm Linux 6.6.31 current-sunxi – Fixed

I’m on Orange Pi One

Armbian 24.5.1 Bookworm with Linux 6.6.31-current-sunxi

I found a fix on this, since I also have issues on the default /etc/ssh/sshd_config  changing port number simply doesn’t work because the ssh.service is running on ssh.socket

I found out that on the /etc/systemd/system/ have 2 files ssh.socket and uuidd.socket  the ssh.socket file is symlinked to /lib/systemd/system/ssh.socket

simply deleting the file ssh.socket file from the /lib/systemd/system/ssh.socket  

will make the /etc/ssh/sshd_config file usable again  after deleting /lib/systemd/system/ssh.socket  file 

execute the command $sudo systemctl daemon-reload

edit the ssh port number from /etc/ssh/sshd_config and put your desired port number (i.e 6120 ) allow the port number from ufw firewall 

restart ssh.service

$ sudo systemctl restart ssh enable ssh service $sudo systemctl enable ssh.service check status and test by logging in on the ssh

$ ssh [email protected] -p 6120

This fix works for me

alternatively you may also change the port number directly  from /lib/systemd/system/ssh.socket

Description=OpenBSD Secure Shell server socket



then execute $sudo systemctl daemon-reload  followed by $sudo sytemctl restart ssh

This alternative fix will still run SSH as a socket service but both of them works fine.

Caveats: to the above procedure as I have updated my system correct fix is below

When a new update for SSH is applied using

$sudo apt update && sudo apt upgrade

The same configuration issue will just revert back to running the SSH using socket.ssh again even if you choose not to overwrite the configuration from the update selection screen.

Your /etc/ssh/sshd_config will not be overwritten, however the deleted /lib/systemd/system/ssh.socket file will be re-created by the update. So restarting or rebooting the SSH server will revert to ssh.socket operation again opening Port number 22, even if you reboot.

The correct fix would be to just disable the port number from /lib/systemd/system/ssh.socket just leave the ListenStream blank to disable the ssh socket. Stop the SSH service using

$sudo systemctl stop ssh  issue $sudo systemctl daemon-reload 

finally restart ssh $sudo systemctl restart ssh  the applied configuration below  from ssh.socket file will revert to ssh server reading 

the /etc/ssh/sshd_config  and will enable the changing port number and other configuration from that file.

###ssh.socket config#####

Description=OpenBSD Secure Shell server socket





As I originally posted on:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.