What should I do if the "Bad configuration options" error is displayed?

Problem Phenomenon


When the SSH service is started on the ECS instance of the Linux system, information similar to the following may appear in the command line or secure log.

/etc/ssh/sshd_config: line 2: Bad configuration options:\ /etc/ssh/sshd_config: terminating, 1 bad configuration options

Problem Causes


The configuration file /etc/ssh/sshd_config corresponding to the SSH service in the ECS instance has abnormalities such as file encoding and configuration errors, which cause the SSH service to fail to start.

Solution


You can choose a suitable solution to repair according to your needs.

Modify the configuration file according to the error message

If the error message clearly indicates the specific wrong configuration, you can modify the corresponding configuration according to the error message.

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

2. Run the following command to open the sshd_config file.

vim /etc/ssh/sshd_config

3. Press the i key to enter edit mode.

4. According to the error prompt, modify the corresponding configuration.

Note You are on a normal ECS instance, compare the /etc/ssh/sshd_config file and modify it.

5. Run sshd in test mode.

/usr/sbin/sshd -t

If no information is returned, it means that the sshd configuration is correct.

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

service sshd start

Upload the sshd_config file in the normal instance to the abnormal instance for repair
If there are many errors, or there is no clear error description in the error message, you can upload the /etc/ssh/sshd_config file of the normal instance to the target abnormal instance for repair.

1. Upload the /etc/ssh/sshd_config file on the normal instance to the target instance through FTP or other methods.

2. Assuming the upload directory is /tmp, execute the following command to copy the file to the normal directory.

cp /tmp/sshd_config /etc/ssh/sshd_config

3. Execute the following command to modify the file permission, owner and group.

chmod 600 /etc/ssh/sshd_config
chown root:root /etc/ssh/sshd_config

Note If the external normal configuration file cannot be uploaded, you can directly edit and compose the configuration file manually according to the normal configuration file.

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

service sshd start

Reinstall the SSH service

If the above operations are inconvenient to implement, you can also refer to the following steps to fix the problem by reinstalling the SSH service.

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

2. Run the following command to uninstall the SSH service.

rpm -e openssh-server

3. Run the following command to install the SSH service.

yum install openssh-server

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

systemctl start sshd.service

Recovery by rolling back the system disk

If none of the above solutions can be repaired, you can restore it by rolling back the historical snapshot of the system disk. For details, see Rolling back a cloud disk using a snapshot.

important

Snapshot rollback will cause data loss after the rollback point, please confirm before proceeding.

It is recommended to try to roll back the snapshots one by one in order of time from recent to far until the SSH service can run normally. If the SSH service still cannot run normally after the rollback, it means that the system at the corresponding time point has been abnormal.

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