免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2396 | 回复: 7
打印 上一主题 下一主题

[FTP] 如何关闭本地用户的ssh登录让其却可以在vsftpd 的chroot 设置用户里登录 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-06-04 17:11 |只看该作者 |倒序浏览
Debian下

如果这样添加用户
useradd username -s /bin/false
则两个服务都登录不了

useradd username -s /usr/sbin/nologin
也是一样的效果

不知道要怎么设置这个

论坛徽章:
34
亥猪
日期:2015-03-20 13:55:11戌狗
日期:2015-03-20 13:57:01酉鸡
日期:2015-03-20 14:03:56未羊
日期:2015-03-20 14:18:30子鼠
日期:2015-03-20 14:20:14丑牛
日期:2015-03-20 14:20:31辰龙
日期:2015-03-20 14:35:34巳蛇
日期:2015-03-20 14:35:56操作系统版块每日发帖之星
日期:2015-11-06 06:20:00操作系统版块每日发帖之星
日期:2015-11-08 06:20:00操作系统版块每日发帖之星
日期:2015-11-19 06:20:00黄金圣斗士
日期:2015-11-24 10:43:13
2 [报告]
发表于 2009-06-04 18:44 |只看该作者
useradd 是添加用户的命令;
-s 定义该用户启动时分配的 shell,如果是 false nologin 这些不是 shell 的命令或者 /abc/def 一类不存在的文件,用户自然没有 shell 使用,以至于不能登陆了。

论坛徽章:
0
3 [报告]
发表于 2009-06-04 18:46 |只看该作者
我用这个半反在RH下可以 debian 想要加一个用户给ftp 但不给ssh 还是没有办法

论坛徽章:
34
亥猪
日期:2015-03-20 13:55:11戌狗
日期:2015-03-20 13:57:01酉鸡
日期:2015-03-20 14:03:56未羊
日期:2015-03-20 14:18:30子鼠
日期:2015-03-20 14:20:14丑牛
日期:2015-03-20 14:20:31辰龙
日期:2015-03-20 14:35:34巳蛇
日期:2015-03-20 14:35:56操作系统版块每日发帖之星
日期:2015-11-06 06:20:00操作系统版块每日发帖之星
日期:2015-11-08 06:20:00操作系统版块每日发帖之星
日期:2015-11-19 06:20:00黄金圣斗士
日期:2015-11-24 10:43:13
4 [报告]
发表于 2009-06-04 20:50 |只看该作者

回复 #3 13251947 的帖子

可以修改 passwd 啊,ssh 的话不是有 sshd.conf 和 hosts.deny 限制么。

论坛徽章:
0
5 [报告]
发表于 2009-06-04 21:18 |只看该作者
http://www.cyberciti.biz/tips/li ... he-sshd-server.html

Linux PAM configuration that allows or deny login via the sshd server
Open SSH Logo

The idea is very simple you want to limit who can use sshd based on a list of users. The text file contains a list of users that may not log in (or allowed to log in) using the SSH server. This is used for improving security.

PAM (Pluggable authentication modules) allows you to define flexible mechanism for authenticating users. My previous post demonstrated how to deny or allow users using sshd configuration option. However, if you want to block or deny a large number of users, use PAM configuration.
A note for new sys admins

   1. Backup all data and PAM configuration files before any modification
   2. Please be careful to perform the configuration option. Wrong configuration can lock down all login access including root access.
   3. Read this Linux-PAM configuration file syntax guide
   4. Now continue reading below for pam_listfile.so configration...

Use of pam_listfile.so module

This PAM module authenticates users based on the contents of a specified file. For example, if username exists in a file /etc/sshd/ssh.allow, sshd will grant login access.
How do I configure pam_listfile.so module to deny access?

You want to block a user, if user-name exists in a file /etc/sshd/sshd.deny file.

Open /etc/pam.d/ssh (or /etc/pam.d/sshd for RedHat and friends)
# vi /etc/pam.d/ssh

Append following line:
auth required pam_listfile.so item=user sense=deny file=/etc/sshd/sshd.deny onerr=succeed

Save and close the file

Now add all usernames to /etc/sshd/sshd.deny file. Now a user is denied to login via sshd if they are listed in this file:
# vi /etc/sshd/sshd.deny

Append username per line:
user1
user2
...

Restart sshd service:
# /etc/init.d/sshd restart

Understanding the config directives:

    * auth required pam_listfile.so : Name of module required while authenticating users.
    * item=user : Check the username
    * sense=deny : Deny user if existing in specified file
    * file=/etc/sshd/sshd.deny : Name of file which contains the list of user (one user per line)
    * onerr=succeed : If an error is encountered PAM will return status PAM_SUCCESS.

How do I configure pam_listfile.so module to allow access?

You want to ALLOW a user to use ssh, if user-name exists in a file /etc/sshd/sshd.allow file.
Open /etc/pam.d/ssh (or /etc/pam.d/sshd for RedHat and friends)
# vi /etc/pam.d/ssh

Append following line:
auth required pam_listfile.so item=user sense=allow file=/etc/sshd/sshd.allow onerr=fail

Save and close the file.

Now add all usernames to /etc/sshd/sshd.allow file. Now a user is allowed to login via sshd if they are listed in this file.
# vi /etc/sshd/sshd.allow

Append username per line:
tony
om
rocky

Restart sshd service (optional):
# /etc/init.d/sshd restart

Now if paul try to login using ssh he will get an error:
Permission denied (publickey,keyboard-interactive).

Following log entry recorded into my log file (/var/log/secure or /var/log/auth.log file)
tail -f /var/log/auth.log

Output:

Jul 30 23:07:40 p5www2 sshd[12611]: PAM-listfile: Refused user paul for service ssh
Jul 30 23:07:42 p5www2 sshd[12606]: error: PAM: Authentication failure for paul from 125.12.xx.xx

Understanding the config directives:

    * auth required pam_listfile.so : Name of module required while authenticating users.
    * item=user : Check or specify the username
    * sense=allow : Allow user if existing in specified file
    * file=/etc/sshd/sshd.allow : Name of file which contains the list of user (one user per line)
    * onerr=fail : If filename does not exists or username formatting is not coreect it will not allow to login.

论坛徽章:
0
6 [报告]
发表于 2009-06-05 10:49 |只看该作者
谢谢,我试一下

论坛徽章:
0
7 [报告]
发表于 2009-06-05 13:23 |只看该作者
sshd_conf 中有  DenyUser选项。

论坛徽章:
0
8 [报告]
发表于 2009-06-09 17:17 |只看该作者

回复 #1 13251947 的帖子

那个实际上是通shell限制用户登陆
具体还是建议通过denyuser限制ssh的使用 通过vsftpd的限制ftp的访问
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP