只准许用户从一个IP登陆本机

php中文网
发布: 2016-06-07 15:30:42
原创
1364人浏览过

vi /etc/pam.d/sshd 加入一行 account required pam_access.so 退出保存 vi /etc/security/access.conf 在尾行加入一行-: guest : ALL EXCEPT 192.168.0. 意思是guest用户从任何的IP地址都不能访问除了192.168.0. 这网段 保存退出 然后测试 # ssh guest@192.

vi /etc/pam.d/sshd
加入一行 account required pam_access.so  
退出保存
vi /etc/security/access.conf
在尾行加入一行-: guest : ALL EXCEPT 192.168.0.
意思是guest用户从任何的IP地址都不能访问除了192.168.0. 这网段
保存退出
然后测试  # ssh guest@192.168.0.8    可以登陆
          # ssh guest@127.0.0.1      不可以登陆
以下为文件的注释
permission : users : origins                                                       大概的意思是
#
# The first field should be a "+" (access granted) or "-" (access denied)
# character.
#
# The second field should be a list of one or more login names, group
# names, or ALL (always matches). A pattern of the form user@host is
# matched when the login name matches the "user" part, and when the
# "host" part matches the local machine name.
#
# The third field should be a list of one or more tty names (for
# non-networked logins), host names, domain names (begin with "."), host
# addresses, internet network numbers (end with "."), ALL (always
# matches) or LOCAL (matches any string that does not contain a "."
# character).
以上的大概意思是
第一个打头的如果为+号(表示准许连接)如果为-号(表示拒绝连接)
第二个应该是你远程TTY的名字也就是说你远程的登陆名字或者组名 ALL(表示匹配所有),你可以在终端输入 user@host
其中user是匹配登陆的名host表示你本机器的IP地址
第三是列出你的登陆名字,或者是网络名,域名别忘记后边要加上点。

本人英语不是很好以上为基本大意如果有问题请多指教共同进步
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号