linux下的hosts.allow和hosts.deny

编程入门 行业动态 更新时间:2024-10-15 12:37:44

<a href=https://www.elefans.com/category/jswz/34/1770067.html style=linux下的hosts.allow和hosts.deny"/>

linux下的hosts.allow和hosts.deny

两个文件可以用来控制远程访问的权限。

hosts.allow对应允许远程连接的用户,hosts.deny对应拒绝远程访问的用户。

以ssh为例:

编辑hosts.deny.

# /etc/hosts.deny: list of hosts that are _not_ allowed to access the system.
#                  See the manual pages hosts_access(5) and hosts_options(5).
#
# Example:    ALL: some.host.name, .some.domain
#             ALL EXCEPT in.fingerd: other.host.name, .other.domain
#
# If you're going to protect the portmapper use the name "rpcbind" for the
# daemon name. See rpcbind(8) and rpc.mountd(8) for further information.
#
# The PARANOID wildcard matches any host whose name does not match its
# address.
#
# You may wish to enable this to ensure any programs that don't
# validate looked up hostnames still leave understandable logs. In past
# versions of Debian this has been the default.
# ALL: PARANOID
sshd:jammgit_1

host.deny文件一些语法(allow类似):

sshd:netid.* // 拒绝一切网络号为netid的主机登陆


那么,当用ssh登陆时会提示:

jammgit@jammg:/etc$ ssh -l jammgit_l localhost
jammgit_l@localhost's password: 
Permission denied, please try again.

注意,当deny和allow的数据有冲突,例如有一个用户既同意又不同意,那么以allow为准。

另一方面,ssh有一个配置文件sshd_config,如果里面设置和hosts.allow和hosts.deny有冲突,那么以sshd_config为准。

如:

#vim sshd_config
...
AllowUsers jammgit_1
...
那么最终是可以登陆的。


hosts是实现dns功能的文件,在局域网机器数量大的情况下应该开启dns服务器。

更多推荐

linux下的hosts.allow和hosts.deny

本文发布于:2024-02-24 14:12:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1695560.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:linux   hosts   deny

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!