What do I do if an error message, such as "This account is currently not available", appears when I connect to a Linux ECS instance by using SSH?

Updated at:

Note

Disclaimer: This article may contain information about third-party products. Such information is for reference only. Alibaba Cloud does not make any guarantee, express or implied, with respect to the performance and reliability of third-party products, as well as potential impacts of operations on the products.

Problem description

When you run an SSH command to log on to a Linux ECS instance, the connection fails and the error message "This account is currently not available." appears even if you enter the correct username and password.

Run the cat /var/log/secure command to view the logon log. Information similar to the following is displayed.

Connection to 127.0.0.1 closed.
Received disconnect from 127.0.0.1: 11: disconnected by user.
pam_unix(sshd:session): session closed for user test.

Causes

This problem usually occurs because the default shell of the corresponding user (such as test) is modified in the user configuration file (/etc/passwd) of the ECS instance, which prevents the user from logging on.

Solution

You can modify the shell of the corresponding user (such as test) to resolve the logon failure.

  1. Log on to the ECS instance by using VNC, as described in Connect using VNC.

  2. Run the following command to view the default shell of the corresponding user (such as test).

    cat /etc/passwd | grep username

    A result similar to the following is displayed, which indicates that the shell of the test user is changed to /sbin/nologin and logon is not allowed.

    test:x:1000:1000::/home/test:/sbin/nologin

  3. Modify the shell of the user.

    Note

    We recommend that you back up files before you modify the policy configuration.

    1. Open the user configuration file (/etc/passwd).

      vi /etc/passwd
    2. Change the default shell of the corresponding user (such as test) to bash. That is, change /sbin/nologin to /bin/bash, as shown in the following example.

      test:x:1000:1000::/home/test:/bin/bash
    3. Press the Esc key, enter :wq, and then save the modification.

  4. Use the user to connect to the Linux instance again and make sure that the connection is normal.

Application scope

  • ECS