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 2222When 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?
54 Answers
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: sdsFrom man page:
-tTest 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.-TExtended 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-Coptions.
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 2 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_configand comment this line:
Subsystem sftp /usr/lib/openssh/sftp-serverI mean change that to:
# Subsystem sftp /usr/lib/openssh/sftp-server 2