I am using centos7.

I was trying to change the port of ssh and I changed the the port in /usr/lib/firewalld/services/ssh.xml

I also change the port in the /etc/ssh/sshd_config file

But when I tried to start the sshd service by "systemctl start sshd" then I am getting the following error.

sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor 
preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Wed 2019-03-27 
16:36:20 IST; 26s ago
 Docs: man:sshd(8)
 Process: 20420 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, 
Main PID: 20420 (code=exited, status=255)

Mar 27 16:36:20 localhost.localdomain systemd[1]: sshd.service: main process 
exited, code=exited, status=255/n/a
Mar 27 16:36:20 localhost.localdomain systemd[1]: Failed to start OpenSSH 
server daemon.
Mar 27 16:36:20 localhost.localdomain systemd[1]: Unit sshd.service entered 
failed state.
Mar 27 16:36:20 localhost.localdomain systemd[1]: sshd.service failed.
  • 4
    paste the output of tail -500 /var/log/secure | grep 'sshd'.
    – erTugRul
    Mar 27, 2019 at 11:39
  • 1
    Is the port already in use by another service?
    – roaima
    Mar 27, 2019 at 11:45
  • 1
  • 3
    If you have SELinux enabled (getenforce shows "Enforcing"), you will need to adapt the security policy to allow sshd to listen to a port other than the default 22. Mar 27, 2019 at 12:38

2 Answers 2


I got the same issue while changing the port from 22.

Upon checking found that SELinux Status is enabled. I have disabled it and check again. Though it was enabled. SELinux Staus will not be changed until you restart your system.

Disabling SELinux and rebooting system fixed my issue and able to change SSH Port.


You need to update the new port no in /etc/services files as well,


ssh 22/tcp # The Secure Shell (SSH) Protocol ssh 22/udp # The Secure Shell (SSH) Protocol

Also check SELinux, as you need to specify the non standard port using semanage tool.

I recommend to visit the REDHAT article to change the port no,


  • 1
    It is not necessary (nor desirable) to modify the list of standard port assignments in /etc/services to match the current local configuration for a service. Aug 12, 2019 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.