How to fix User user from hostname not allowed because not listed in AllowUsers in SSH

SSHINTERMEDIATEHIGHUpdated Jan 4, 2026· 281 views

This error occurs when sshd_config restricts SSH login to specific users via the AllowUsers directive. Fix it by adding your username to the AllowUsers list in sshd_config and restarting the SSH service.

Quick fix

Fixes User user from hostname not allowed because not listed in AllowUsers

grep -i allowusers /etc/ssh/sshd_config
  1. Check current AllowUsers configuration
  2. Edit sshd_config to add your user
  3. Include root if you need root access
  4. Verify sshd_config syntax
ssh — error
grep -i allowusers /etc/ssh/sshd_config
User user from hostname not allowed because not listed in AllowUsers

What this error means

The SSH daemon (sshd) has access control rules configured in /etc/ssh/sshd_config that explicitly whitelist which users are allowed to authenticate. The AllowUsers directive creates a list of permitted user accounts—if it is set, only users in that list can log in via SSH. When a user attempts to connect and is not in the AllowUsers list, the connection is rejected with this error message. This is a security feature that restricts SSH access to specific accounts, preventing unauthorized users from attempting login. However, if configured incorrectly, it can accidentally lock out legitimate users, including administrative accounts.

Typical symptoms

  • SSH connection attempts fail immediately with "User ... not allowed because not listed in AllowUsers" in auth.log
  • Error appears after sshd_config is modified with AllowUsers directive
  • Some users can connect while others cannot, depending on AllowUsers configuration
  • Authentication succeeds locally (at the terminal) but fails over SSH

Common causes

  1. The user account attempting SSH login is not listed in the AllowUsers directive in /etc/ssh/sshd_config
  2. AllowUsers directive was added but the current user was forgotten (common when adding specific users)
  3. Typo in the username within the AllowUsers list
  4. AllowUsers is used together with AllowGroups, and the user is not in a group listed in AllowGroups
  5. Incorrect spacing or formatting in sshd_config (tabs vs spaces) preventing proper parsing

How to fix "User user from hostname not allowed because not listed in AllowUsers"

1Check current AllowUsers configuration

Open the sshd_config file and view the AllowUsers directive:

bash
grep -i allowusers /etc/ssh/sshd_config

If the line is commented out (starts with #) or missing, AllowUsers is not active and this is not the issue. If the line exists and your username is not listed, proceed to the next step.

2Edit sshd_config to add your user

Edit the SSH configuration file with sudo:

bash
sudo nano /etc/ssh/sshd_config

Find the line starting with AllowUsers. If multiple users need access, add them space-separated on the same line:

bash
AllowUsers user1 user2 user3

Or add the user to an existing AllowUsers line:

bash
AllowUsers admin developer

If the line does not exist, add it. Use Tab (not spaces) between "AllowUsers" and the usernames for proper parsing.

3Include root if you need root access

If you need root-level SSH access, add root to the AllowUsers list:

bash
AllowUsers root admin user1

Without root in AllowUsers, you cannot SSH as root, even with valid credentials. This is why the root user should almost always be included if AllowUsers is set.

4Verify sshd_config syntax

Before restarting sshd, test that your configuration file is valid:

bash
sudo sshd -t

If the command returns nothing, the syntax is correct. If there is an error, fix the issue in sshd_config and test again.

5Restart the SSH service

Apply the changes by restarting sshd:

bash
sudo systemctl restart sshd

Or on older systems:

bash
sudo service ssh restart

Always keep an existing SSH session open until you verify the new connection works, in case you need to roll back the configuration.

6Test SSH access from another terminal

Open a new terminal or SSH session and attempt to log in:

bash
ssh user@hostname

If the connection succeeds, the error is resolved. If it still fails, check /var/log/auth.log for additional error details:

bash
tail -f /var/log/auth.log | grep sshd

Advanced notes

When both AllowUsers and AllowGroups are set in sshd_config, a user must satisfy BOTH conditions: they must be listed in AllowUsers AND belong to a group in AllowGroups. If using AllowGroups, ensure your user is in one of the specified groups.

On Windows systems running OpenSSH, AllowUsers/AllowGroups directives may not work correctly with domain users without additional configuration. A workaround is to create a local group and nest the domain group within it, then use AllowGroups to reference the local group.

For security, SSH access as root is discouraged. Instead, create a dedicated admin user, add it to the AllowUsers list, and use sudo for administrative tasks.

Frequently asked questions

What does "User user from hostname not allowed because not listed in AllowUsers" mean?
The SSH daemon (sshd) has access control rules configured in /etc/ssh/sshd_config that explicitly whitelist which users are allowed to authenticate. The AllowUsers directive creates a list of permitted user accounts—if it is set, only users in that list can log in via SSH. When a user attempts to connect and is not in the AllowUsers list, the connection is rejected with this error message.
How do I fix "User user from hostname not allowed because not listed in AllowUsers"?
This error occurs when sshd_config restricts SSH login to specific users via the AllowUsers directive. Fix it by adding your username to the AllowUsers list in sshd_config and restarting the SSH service.
What causes "User user from hostname not allowed because not listed in AllowUsers"?
The user account attempting SSH login is not listed in the AllowUsers directive in /etc/ssh/sshd_config AllowUsers directive was added but the current user was forgotten (common when adding specific users) Typo in the username within the AllowUsers list
Is the "User user from hostname not allowed because not listed in AllowUsers" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading