Help Center> Elastic Cloud Server> Troubleshooting> Passwords and Key Pairs Issues> How Do I Change the Login Mode of a Linux ECS from Key Pair to Password?
Updated on 2022-07-15 GMT+08:00

How Do I Change the Login Mode of a Linux ECS from Key Pair to Password?

Scenarios

This section describes how to change the login mode of a Linux ECS from key pair to password.

Procedure

  1. Use the key to log in to the Linux ECS and set the password of user root.

    sudo passwd root

    If the key file is lost or damaged, reset the password of user root. For details, see How Can I Reset the Password for User root in the Single-User Mode on a Linux ECS?

  2. Modify the SSH configuration file on the ECS as user root.

    su root

    vi /etc/ssh/sshd_config

    Modify the following settings:

    • Change PasswordAuthentication no to PasswordAuthentication yes.

      Alternatively, delete the comment tag (#) before PasswordAuthentication yes.

    • Change PermitRootLogin no to PermitRootLogin yes.

      Alternatively, delete the comment tag (#) before PermitRootLogin yes.

  3. Restart sshd for the modification to take effect.

    service sshd restart

  4. Restart the ECS. Then, you can log in to the ECS as user root using the password.

    To prevent unauthorized users from using the key file to access the Linux ECS, delete the /root/.ssh/authorized_keys file or clear the authorized_keys file.