I have been looking around and couldn't find a solution to the issue I am having. I am running Ubuntu 16.04 LTS, and I followed instructions on the Ubuntu page for changing the SSH port to 2222 by updating the sshd_config file.

# What ports, IPs and protocols we listen for
Port 2222

When I execute the command sudo systemctl restart sshd.service, however, I only get the following error:

Job for ssh.service failed because the control process exited with error code. See "systemctl status ssh.service" and "journalctl -xe" for details.

I then executed the command systemctl status ssh.service and got

● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2016-09-07 23:24:04 EDT; 1min 28s ago
  Process: 16813 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (code=exited, status=255)
 Main PID: 16813 (code=exited, status=255)

Sep 07 23:24:04 sys-0 systemd[1]: Starting OpenBSD Secure Shell server...
Sep 07 23:24:04 sys-0 systemd[1]: ssh.service: Main process exited, code=exited, status=255/n/a
Sep 07 23:24:04 sys-0 systemd[1]: Failed to start OpenBSD Secure Shell server.
Sep 07 23:24:04 sys-0 systemd[1]: ssh.service: Unit entered failed state.
Sep 07 23:24:04 sys-0 systemd[1]: ssh.service: Failed with result 'exit-code'.

What does the error mean, and how can I address it?

| |
  • 3
    Most likely you made a simple mistake in your sshd_config. What if you put back the original one? – techraf Sep 8 '16 at 4:07
  • sudo sshd -vvvf /etc/ssh/sshd_config should give you clue as to what is wrong – Paul Sep 8 '16 at 5:00
  • When I put back the original one, it works as usual. However, port 2222 worked for me today doing the exact same thing I did last night. Very odd. – FullStack Sep 8 '16 at 12:43
  • @techraf I deleted the other one. I'm never sure which SE is better for this type of question – FullStack Sep 8 '16 at 12:43
  • @Paul on openssh-server 1:7.4p1-10+deb9u2 on Debian 9 I get unknown option -- v. – Pablo A Feb 1 '18 at 16:24

As @techraf said, most likely you made a simple mistake in your /etc/ssh/sshd_config. Try sshd test mode:

$ sudo sshd -t
/etc/ssh/sshd_config: line 1: Bad configuration option: sds

From man page:

  • -t Test mode. Only check the validity of the configuration file and sanity of the keys. This is useful for updating sshd reliably as configuration options may change.
  • -T Extended test mode. Check the validity of the configuration file, output the effective configuration to stdout and then exit. Optionally, Match rules may be applied by specifying the connection parameters using one or more -C options.
| |

Are you running on a system that utilizes SELinux? It could be that this is denying the port bind; try adding in a new rule.

semanage port -a -t ssh_port_t -p tcp 2222
| |
  • no, I am not running on SELinux, but somehow this morning doing the same things worked. Thanks so much for your input – FullStack Sep 8 '16 at 12:44
  • Thanks this helped me! – DomenicDatti Mar 20 '19 at 19:18

I hade the same error. After banging my head against the wall for a while I've found out, that I've destroyed the /etc/passwd entries by running a custom-made-linux-server-setup-bash-script which worked well previously, but this time the regex within the "sed" command erased all the existing entries :D After copy pasting the default entries from another working linux server I could finally restart sshd.

So don't forget to backup the original /etc/passwd file before applying any regex replacements on it :)

| |

Edit sshd_config

sudo nano /etc/ssh/sshd_config

and comment this line:

Subsystem sftp /usr/lib/openssh/sftp-server

I mean change that to:

# Subsystem sftp /usr/lib/openssh/sftp-server
| |
  • Still the same error, nothing has changed – Sayali Sep 12 '18 at 6:26

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.