How to Resolve Unable to Log in to Linux BCC Instance via SSH
When attempting to sign in to a Linux instance via SSH, you may encounter a message stating that the connection cannot be established or has failed, preventing normal sign-in to the instance.
Based on the returned error message, you may record the error messages
User root not allowed because not listed in AllowUsers
Cause of problem
This issue often arises when the SSH service enforces user login restrictions via specified parameters. The parameters are described as follows:
AllowUsers: Specifies users who are allowed to sign in. Only the users listed under this parameter can log in.
DenyUsers: Specifies users who are denied sign-in access. All users listed under this parameter are blocked from signing in.
AllowGroups: Specifies groups whose members are permitted to sign in. Only users within these groups can log in.
DenyGroups: A blacklist of groups not allowed to sign in. Any group specified by this parameter is prevented from signing in.
Note: Deny policies override allow policies.
Solution
- Sign in to the BCC instance via VNC, edit /etc/ssh/sshd_config, and annotate or delete the following content:
AllowUsers username
DenyUsers username
DenyGroups groupname
AllowGroups groupname
Restart the sshd service, taking centos 7 as an example:
systemctl restart sshd
- Disconnected:No supported authentication methods available Problem phenomenon:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
Cause of problem
Password authentication for login is disabled in the sshd_config file.
Solution
Edit /etc/ssh/sshd_config, and modify PasswordAuthentication no to PasswordAuthentication yes Restart the sshd service
ssh_exchange_identification: read: Connection reset by peer When signing in via SSH, the following error messages appear
"ssh_exchange_identification: Connection closed by remote host"
"kex_exchange_identification: read: Connection reset by peer"
"kex_exchange_identification: Connection closed by remote host"
Cause of problem
Access control restricts connections
Firewall rules are modified
Maximum connection limit in sshd configuration
Network issues exist
Solution
Review and adjust access policy settings.
Using CentOS 7 as an example, configure access policies via the /etc/hosts.allow and /etc/hosts.deny files, which respectively define allowed and denied policies.
For instance, specify trusted hosts in the hosts.allow file and blocked hosts in the hosts.deny file.
The block policy is as follows [Example]
1sshd:180.76.100.35:deny #It indicates denying the sshd request from IP 180.76.100.35!
2 sshd:all:deny #It indicates denying all sshd remote connections.
3 Note: deny can be omitted.
If blocking policies are configured, remove the corresponding settings as necessary.
Inspect and modify the sshd configuration.
Check if the MaxStartups value requires adjustment. The maximum allowed connections are set in the sshd_config file through the MaxStartups parameter. If additional connections need to be established quickly, adjust this value accordingly.
The default MaxStartups configuration is 10:30:100, which defines the limits for unauthenticated concurrent connections in the SSH daemon. Specifically, connections exceeding 10 are rejected with a progressively increasing 30% probability until the count reaches 100.
Check iptables firewall rules
Run the following command to verify whether SSH connections are being blocked by the firewall.
iptables -L --line-number If SSH is blocked, update the firewall rules to unblock SSH.
Permission denied, please try again
Cause of problem
The sshd_config configuration file is configured with: PermitRootLogin no
Solution
Modify the /etc/ssh/sshd_config file to change PermitRootLogin from "no" to "yes".
Restart the sshd service
Too many authentication failures
Cause of problem
Upon entering the wrong password multiple times consecutively, the SSH service's password reset policy will be triggered.
Solution
Verify in the /etc/ssh/sshd_config file whether the MaxAuthTries parameter is appropriately configured.
If the following settings appear
MaxAuthTries 6 Maximum SSH password attempt failures: 6 Edit the /etc/ssh/sshd_config, delete or comment out the MaxAuthTries settings, and restart the sshd service.
