您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2025/11/7 17:26:02发布29次查看
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地址
第三是列出你的登陆名字,或者是网络名,域名别忘记后边要加上点。
本人英语不是很好以上为基本大意如果有问题请多指教共同进步
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product