当前位置:Gxlcms > mysql > 只准许用户从一个IP登陆本机

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

时间:2021-07-01 10:21:17 帮助过:30人阅读

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地址
第三是列出你的登陆名字,或者是网络名,域名别忘记后边要加上点。

本人英语不是很好以上为基本大意如果有问题请多指教共同进步

人气教程排行