# How to restrict user logins to SSH

Source: https://www.hukot.net/community/en/tutorials/how-to-restrict-user-logins-to-ssh
Updated: 2026-11-25

If we want to allow SSH login only to specific users, we need to edit the SSH configuration file.

`nano /etc/ssh/sshd_config`

At the end of the file, we add the **AllowUsers** line and a space-separated list of usernames. For example, if we have users kate and dave and we want them both to have access to SSH.

`AllowUsers kate dave`

> [!WARNING]
> Include your own account in the list, otherwise you will not be able to log in over SSH after the restart. If the file ends with an active `Match` block, add the line above it, otherwise it applies only inside the block. Close your current session only after you have tested the login.

Restart the SSH service and now only the specified users will log in.
