Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

If CentOS 7 says Unit sshd.service could not be found, the usual cause is that the OpenSSH server package is missing. Install openssh-server, start the unit, enable it for future boots, and then verify the firewall and SELinux policy if remote clients still cannot connect.

What “sshd.service not found” means on CentOS 7

Systemd can manage only units that exist on the system. On CentOS 7, the OpenSSH server package supplies the SSH daemon and its systemd unit. Red Hat’s RHEL 7 administration guidance states that an OpenSSH server requires the openssh-server package. The unit is named sshd.service, and its daemon configuration is stored in /etc/ssh/sshd_config.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Therefore, a missing-unit error is normally a package problem, not a failed network connection. A machine may have SSH client tools and still lack the server daemon. Until the server package is installed, commands such as systemctl start sshd.service or systemctl status sshd.service have no unit to start or inspect.

Install and activate the SSH server

Use a root shell or an account with sudo privileges. These commands install the server, start it for the current boot, configure automatic startup, and show its state:

  1. sudo yum install -y openssh-server
  2. sudo systemctl start sshd.service
  3. sudo systemctl enable sshd.service
  4. sudo systemctl status sshd.service

start changes the service state immediately for the current boot. enable creates the boot-time configuration so the daemon starts after a reboot. They are separate operations: starting without enabling leaves the service stopped after the next boot, while enabling without starting does not necessarily provide an SSH listener until the next restart.

A successful status result should identify sshd.service as loaded and active. If the installation completes but the status command still says the unit cannot be found, verify the package installation before investigating systemd.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check whether the server package is installed

Query the RPM database directly:

rpm -q openssh-server

If the query reports that the package is not installed, run the yum install command again and read the complete error. Do not replace the package with an unrelated name; the required server package is openssh-server.

When yum cannot find openssh-server

An error such as “No package openssh-server available” points to enabled repositories, repository metadata, or network access to the repository. It is not a systemd service failure. Capture the exact yum output and inspect which repositories are enabled in that environment. Correct the repository or connectivity problem first, then repeat the package query and installation.

Do not proceed by creating a hand-written systemd unit as a substitute. A locally fabricated unit can hide the real packaging problem and leave the daemon, configuration, and lifecycle integration inconsistent with the CentOS installation.

Validate sshd_config before restarting

Any edit to /etc/ssh/sshd_config should be syntax-checked before a restart:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo sshd -t

A successful test normally produces no output. If it names a line or directive, correct that entry and run the test again. A syntax error can prevent the daemon from starting and can lock you out if you close your only administrative session.

Keep an existing console, hypervisor console, or other out-of-band session open while changing SSH settings. Do not rely on the connection you are about to restart as your only recovery path.

After the test succeeds, restart and inspect both the immediate status and the boot journal:

sudo systemctl restart sshd.service
sudo systemctl status sshd.service
sudo journalctl -u sshd -b

The journal command limits the view to the current boot, making it useful for errors reported during the latest start attempt. Read the first concrete configuration, permission, or bind error rather than repeatedly restarting the service.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When sshd is active but remote connections fail

A running daemon proves only that sshd started locally. A remote connection must also pass through the host firewall, any upstream firewall or security group, routing, and the address and port on which sshd is listening. Start with the host firewall checks:

sudo systemctl status firewalld
sudo firewall-cmd --state
sudo firewall-cmd --list-services

When firewalld is enabled and the server uses the standard SSH service, permit it permanently and reload the active rules:

sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload

The permanent change updates the saved firewall configuration; --reload applies it without stopping the firewall service. Check the state again after reloading if you need to confirm that the daemon accepted the rule.

If the host firewall allows SSH but clients still time out, investigate controls outside sshd: an upstream firewall or cloud security group, an incorrect route, an address that is not reachable from the client network, or a port mismatch. A timeout is not evidence that the unit is missing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Using a non-standard SSH port

If /etc/ssh/sshd_config contains a changed Port value, every enforcement layer must agree on that port. Changing the daemon setting alone is insufficient.

  1. Run sudo sshd -t and correct any reported configuration error.
  2. Permit the selected TCP port in firewalld. The standard ssh service rule covers the conventional SSH port; a custom port needs a matching firewall rule.
  3. On SELinux systems, label the port with the SSH port type. For port 2222, use sudo semanage port -a -t ssh_port_t -p tcp 2222.
  4. Restart the daemon and verify its status with sudo systemctl restart sshd.service and sudo systemctl status sshd.service.
  5. Tell the client which port to use: ssh -p 2222 user@host.

SELinux can reject a bind to a port that is not labeled ssh_port_t, even when the sshd configuration is syntactically valid. Firewalld and SELinux solve different problems, so both must be updated for a custom port.

Best Value
Sale
UNIX and Linux System Administration Handbook, 4th Edition
  • New
  • Mint Condition
  • Dispatch same day for order received before 12 noon
  • Guaranteed packaging
  • No quibbles returns

Diagnose the failure by layer

Use the first symptom that matches what you see, then stay within that layer until it is resolved:

Symptom Likely layer Action
Unit sshd.service could not be found Package Run rpm -q openssh-server. If absent, install it with sudo yum install -y openssh-server.
Yum cannot locate openssh-server Repository or network Read the complete yum error and repair enabled repositories or repository connectivity.
sshd -t names a line or directive Configuration Fix the named entry in /etc/ssh/sshd_config, then repeat the test.
Service fails after an edit Configuration or startup Run systemctl status sshd and journalctl -u sshd -b to identify the startup error.
Service is active but clients time out Firewall or network path Check firewalld state and services, then check upstream firewalls, security groups, routing, and the expected address and port.
Custom port is denied Firewall or SELinux Allow the TCP port in firewalld and label it ssh_port_t with semanage.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Temporary start versus persistent startup

Goal Command Effect
Start SSH now sudo systemctl start sshd.service Starts sshd for the current boot; it does not by itself configure boot-time startup.
Start SSH automatically after reboot sudo systemctl enable sshd.service Records the service as enabled for future boots.
Apply a configuration change now sudo systemctl restart sshd.service Stops and starts the daemon; validate with sshd -t first.
Inspect current state sudo systemctl status sshd.service Shows whether the unit is loaded, running, failed, or missing.

For a normal server installation, use both start and enable. Treat a restart as a potentially disruptive operation when you are connected over SSH.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why localhost can work while remote SSH fails

A local test and a remote test exercise different portions of the path. A localhost connection reaches the daemon without crossing the external interface, host firewall path, upstream network controls, or client-side route. Consequently, local success does not prove that another machine can reach the server.

  • If sshd is active but a remote client times out, examine firewalld and upstream filtering before changing the daemon configuration.
  • If a remote client immediately receives a refusal, confirm that sshd is running and that the client is using the configured port.
  • If a custom port was selected, verify the daemon’s Port value, firewalld rule, SELinux ssh_port_t label, and client command as one set.
  • If the service will not start at all, use sshd -t, systemctl status sshd, and journalctl -u sshd -b before investigating the network.

A safe end-to-end recovery sequence

This sequence separates installation, configuration, service state, and network access so that each result narrows the diagnosis:

  1. Keep a console or out-of-band session available.
  2. Run rpm -q openssh-server.
  3. If the package is absent, run sudo yum install -y openssh-server. If yum fails, resolve its repository or network error before continuing.
  4. Run sudo sshd -t. Repair /etc/ssh/sshd_config if a directive or line is reported.
  5. Start the daemon with sudo systemctl start sshd.service.
  6. Enable boot-time startup with sudo systemctl enable sshd.service.
  7. Confirm the result with sudo systemctl status sshd.service.
  8. If startup fails, read sudo journalctl -u sshd -b.
  9. If startup succeeds but remote access fails, inspect firewalld using systemctl status firewalld, firewall-cmd --state, and firewall-cmd --list-services.
  10. If the SSH port is non-standard, allow it in firewalld, label it ssh_port_t, restart sshd, and connect with the matching ssh -p option.

Final CentOS 7 SSH checklist

  • openssh-server is installed and confirmed with rpm -q openssh-server.
  • sshd -t completes without a configuration error.
  • sshd.service is started for the current boot.
  • sshd.service is enabled for future boots when persistent access is required.
  • systemctl status sshd.service shows the expected running state.
  • journalctl -u sshd -b has been checked when startup fails.
  • Firewalld permits the port clients are actually using.
  • Upstream security groups, routing, and network firewalls permit the same destination.
  • Any non-standard port is labeled with SELinux type ssh_port_t.
  • An existing administrative session remains open until the new connection is tested.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.