All Products
Search
Document Center

Elastic Compute Service:What do I do if I cannot connect to a Linux ECS instance by using a password?

最終更新日:Aug 08, 2024

This topic describes the cause of and solution to the following issue: The Logon failed because password-based logon is disabled in the operating system error message appears when you connect to a Linux Elastic Compute Service (ECS) instance by using Workbench.

Problem description

When you connect to a Linux ECS instance by using a password on Workbench, the following error message appears: Logon failed because password-based logon is disabled in the operating system.

无法登录ECS

Cause and solution

The preceding issue may occur due to the following reasons:

  • No logon password was configured when the ECS instance was created. In this case, you can configure a logon password for the ECS instance. For more information, see Reset the logon password of an instance.

  • The account that you use has overdue payments. If you connect to the ECS instance by using the public IP address of the instance, the connection fails due to overdue payments in your account. In this case, you can use the private IP address of the instance to connect to the ECS instance or complete the overdue payments and then connect to the ECS instance.

  • An SSH key pair is bound to the ECS instance. If an SSH key pair is bound to the ECS instance, password-based authentication is automatically disabled for the instance. To enable password-based authentication for the ECS instance, you can reset the logon password of the instance or modify the SSH configuration file. For more information, see Reset the logon password of an instance or the Modify the SSH configuration file section of this topic.

Modify the SSH configuration file

Connect to the ECS instance by using key pair-based authentication or by using Virtual Network Computing (VNC) based on your business requirements and modify the SSH configuration file.

  1. Connect to the ECS instance by using key pair-based authentication or by using VNC.

    For more information, see Connect to a Linux instance by using a password or key or Connect to an instance by using VNC.

  2. Check the value of the PasswordAuthentication parameter in the /etc/ssh/sshd_config file.

    cat /etc/ssh/sshd_config

    The following figure shows that the PasswordAuthentication parameter is set to no, which indicates that password-based authentication is disabled. To enable password-based authentication, set the PasswordAuthentication parameter to yes.

    PermitRootLogin no

  3. Change the value of the PasswordAuthentication parameter to yes.

    1. Open the SSH configuration file.

      sudo vim /etc/ssh/sshd_config
    2. Change PasswordAuthentication no to PasswordAuthentication yes.PermitRootLogin yes

    3. Press the Esc key, enter :wq, and then press the Enter key to save the change.

  4. Restart the sshd service for the change to take effect.

    sudo systemctl restart sshd.service
  5. Connect to the ECS instance by using a password. If you can connect to the ECS instance, the issue is resolved.

    For more information, see Connect to a Linux instance by using a password or key.