我目前可以以 root 身份通过 ssh 登录到我的服务器。但是,可能还有一些其他用户具有 ssh 访问权限。我想阻止除 root 之外的任何可能的登录。我怎样才能做到这一点?
谢谢。
小智 10
因此,您可以使用 sshd_config 文件中的 AllowUsers 指令来实现您的愿望,例如:
$ grep AllowUsers /etc/ssh/sshd_config
AllowUsers root
Run Code Online (Sandbox Code Playgroud)
但是,我会谨慎使用 root 帐户进行 ssh - 考虑使用非特权帐户进行正常使用,仅在需要时使用 sudo 之类的东西来获取 root 权限。
小智 5
AllowUsers
This keyword can be followed by a list of user name patterns, separated
by spaces. If specified, login is allowed only for user names that match
one of the patterns. Only user names are valid; a numerical user ID is
not recognized. By default, login is allowed for all users. If the pat?
tern takes the form USER@HOST then USER and HOST are separately checked,
restricting logins to particular users from particular hosts. The
allow/deny directives are processed in the following order: DenyUsers,
AllowUsers, DenyGroups, and finally AllowGroups.
See PATTERNS in ssh_config(5) for more information on patterns.
Run Code Online (Sandbox Code Playgroud)
顺便提一句。请不要让您的 root 用户使用密码登录。只允许 ssh 密钥,甚至更好地只允许特定用户登录并更改为 root 而不是直接 root。
归档时间: |
|
查看次数: |
5051 次 |
最近记录: |