All Products
Search
Document Center

An SSH remote connection exception occurs in a Linux instance because SELinux is enabled.

Last Updated: Sep 21, 2020

Problem description

In SSH remote connectionConnectFor Linux instances, Even if the password is entered correctly,On the command line orThe following error message is also displayed in secure logs.

Permission denied, please try again.
error: Could not get shadow infromation for root.

 

Causes

This problem is usually caused by the SELinux service enabled.

 

Solution

You can choose to temporarily or permanently disable SELinux to solve SSH connection exceptions based on the on-site environment requirements.

 

Check the SELinux service status

  1. PassManagement terminalLog on to the Linux instance and run the following command to check the current SELinux Service Status.
    /usr/sbin/sestatus -v 
    A similar output is displayed.
    SELinux status:       enabled
    Note:IfSELinux statusThe parameter isEnabledIs enabledDisabledIs disabled.

 

Temporarily disable SELinux

Log on to the Linux instance and run the following command to temporarily disable SELinux.

Note:You can modify the SELinux service status in real time without restarting the system or instance.

setenforce 0

 

Disable SELinux permanently

Log on to the Linux instance and run the following command to disable SELinux permanently.

Note:The SELinux service status can only be changed permanently after the system or instance is restarted.

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

Note:This command is only applicable to the current SELinux serviceEnforcingStatus.

 

Application scope

  • ECS