What Errors Are Prompted When Starting the SSH Service

What should I do if the error "fatal: Cannot bind any address" is displayed when I start the SSH service in the ECS instance of the Linux system?


Problem Phenomenon


When starting the SSH service in the ECS instance of the Linux system, an error message similar to the following appears on the command line or in the Secure log.

FAILED.
fatal: Cannot bind any address.
address family must be specified before ListenAddress.

Problem Causes


This problem may be caused by the fact that the AddressFamily in the configuration file /etc/ssh/sshd_config of the SSH service in the ECS instance is configured as inet6, but the ECS instance does not enable IPv6 or the IPv6 protocol is incorrectly configured, causing this problem.

Solution


1. Remotely connect to the ECS instance via VNC.

2. Execute the following command to view the /etc/ssh/sshd_config configuration file.

cat /etc/ssh/sshd_config

When the returned information contains the following content, it indicates that the IPv6 protocol suite is configured.

AddressFamily inet6

Explanation The value of the AddressFamily parameter is described as follows.

inet: Use the IPv4 protocol family, which is the default value.
inet6: Use the IPv6 protocol family.
any: Enables both IPv4 and IPv6 protocol suites.

3. Modify the AddressFamily parameter value.

Important When modifying, please ensure that the AddressFamily parameter is configured before ListenAddress to take effect.

a. Execute the following command to open the /etc/ssh/sshd_config configuration file.

vim /etc/ssh/sshd_config

b. Press i key to enter edit mode.

c. Set AddressFamily to inet, or add # before AddressFamily to comment the configuration, as shown below.

# AddressFamily inet6 #Comment the configuration

AddressFamily inet4 #Use IPv4 protocol cluster

d. After pressing the Esc key, type :wq and press Enter to save and close the configuration file.

4. Run the following command to restart the SSH service.

systemctl restart sshd.service

In the ECS instance of the Linux system, no error message is encountered when starting the SSH service, but the ssh service is not started, what should I do?


Problem Phenomenon



In an ECS instance of the Linux system, when the service or systemctl command is used to start the SSH service, the command line does not return any error message, but the service does not run normally.

Execute cat /var/log/secure to view the secure log, and find error messages similar to the following.

sshd.service: main process exited, code=exited, status=203/EXEC.
init: ssh main process (1843) terminated with status 255.

Problem Causes


This problem is usually caused by abnormal configuration of the PATH environment variable or removal of related files of the SSH package.

Solution


Please follow the steps below to check and solve the problem.

1. Use VNC to remotely connect to the ECS instance.

2. Execute the following command to check the environment variable configuration.

echo $PATH

• The system normally returns something like the following, which is the default value of the PAHT environment variable.

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

• If other information is returned, it means that the default value of the environment variable has been changed, you need to execute the following command to reset the environment variable.

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

3. Execute the following command to find and confirm the path of the sshd program.

find / -name sshd

• The system normally returns something like the following, including the default path of the sshd program.

/usr/sbin/sshd

• If the corresponding file does not exist, it is recommended to run the following command to reinstall the SSH software package.

yum install -y openssh

4. Run the following command to restart the SSH service.

systemctl restart sshd.service

5. Run the following command to check the status of the SSH service.

systemctl status sshd.service

When the following is returned, it means that the SSH service is running.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us