1

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)
       man:sshd_config(5)
 Process: 20420 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, 
status=255)
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.
  • 2
    paste the output of tail -500 /var/log/secure | grep 'sshd'. – erTugRul Mar 27 at 11:39
  • 1
    Is the port already in use by another service? – roaima Mar 27 at 11:45
  • 1
  • 2
    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. – Ulrich Schwarz Mar 27 at 12:38
0

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

example:

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,

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/managing_confined_services/sect-managing_confined_services-configuration_examples-changing_port_numbers

  • 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. – user4556274 Aug 12 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.