Chinaunix首页 | 论坛 | 博客
  • 博客访问: 500155
  • 博文数量: 58
  • 博客积分: 6012
  • 博客等级: 准将
  • 技术积分: 1211
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-09 22:50
文章分类

全部博文(58)

文章存档

2010年(25)

2009年(23)

2008年(10)

我的朋友

分类: 网络与安全

2008-09-24 19:49:22

安装:
# apt-get install libpam-encfs encfs
# wget
--之前安装的libpam-encfs存在BUG,
# apt-get purge libpam-encfs && dpkg -i libpam-encfs_0.1.2-2_i386.deb
# grep fuse /etc/modules || echo "fuse">>/etc/modules
# usermod -a -G fuse wang

第一次使用:
# mkdir -p /var/data/.enc/wang /home/wang
# encfs /var/data/.enc/wang /home/wang
# cd /home/wang
# echo "Hello, world!">abc.txt
# fusermount -u /home/wang

第二次使用:
# encfs /var/data/.enc/wang /home/wang
……
# fusermount -u /home/wang

使用多个密码保护不同的文件:
# encfs --anykey /var/data/.enc/wang /home/wang
---提示出入密码,这时输入另外一个不同的密码
# cd /home/wang
# l
---发现没有文件,上面创建的文件abc.txt根本看不到。这时由于encfs只显示能成功解密的文件,密码不同,所以没法解密以前生成的文件。
# l / > 123.txt
# fusermount -u /home/wang
# encfs --anykey /var/data/.enc/wang /home/wang
---提示出入密码,这时输入开始的那个密码
# cd /home/wang
--这时有可以看见文件abc.txt了,但是看不到文件123.txt。
# fusermount -u /home/wang
因此可以想到,对于同一个加密目录可以采用许多个密码分别保护不同的文件。这对于多个人共享同一个目录却又互相防备非常有用。

采用超级复杂密码:
# dd if=/dev/urandom of=/path/to/password bs=1 count=512
# cat /path/to/password | encfs -S --anykey /var/data/.enc/wang /home/wang

修改密码:
# encfsctl passwd /var/data/.enc/wang

登录时自动安装主目录:
# mv /etc/pam_encfs.conf /etc/security/
# ln -sv /etc/security/pam_encfs.conf /etc/
# cat /etc/pam_encfs.conf:
#Note that I dont support spaces in params
#So if your for example gonna specify idle time use --idle=X not -i X.

#If this is specified program will attempt to drop permissions before running encfs. (will not work with --public for example)
drop_permissions

#This specifies default encfs options
encfs_default --idle=1

#Same for fuse, note that allow_root (or allow_other, or --public in encfs) is needed to run gdm/X.
#fuse_default allow_root
fuse_default nonempty

#- means match all, put any overrides over it.
#if - is in username it will take source path + "/$USER", and mount to $HOME

#USERNAME        SOURCE             TARGET PATH      ENCFS Options        FUSE Options
#anders        /home/.enc/anders    /home/bennett    -v,--idle=1,-test,-test2        allow_root
#prueba        /home/.enc/prueba    /home/prueba    -v
-        /home/.enc    -         -            -

# cat /etc/fuse.conf:
# Set the maximum number of FUSE mounts allowed to non-root users.
# The default is 1000.
#
#mount_max = 1000

# Allow non-root users to specify the 'allow_other' or 'allow_root'
# mount options.
#
#user_allow_other
#allow_root

# cat /etc/pam.d/comman-auth:
auth    requisite  pam_encfs.so
auth    requisite  pam_unix.so nullok_secure use_first_pass

# grep "unset HISTFILE" /etc/profile || echo "unset HISTFILE" >> /etc/profile
# mkdir -p /home/.enc/test /home/test
# groupadd -g 5000 moodisk
# useradd -e 06/01/08 -g moodisk -G fuse -u 1000 -s /usr/sbin/nologin test

限制组fuse的用户通过SSH登录,但可以SFTP:
把“/usr/bin/id|/bin/grep fuse 1>/dev/null && exit“加到文件/etc/profile的首部。

配置系统使用ldap库中的用户:
# cat /etc/nsswitch.conf
passwd:         files ldap [NOTFOUND=return] db
group:          files ldap [NOTFOUND=return] db
shadow:         files ldap [NOTFOUND=return] db

#passwd:         files
#group:          files
#shadow:         files

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       ldap [NOTFOUND=return] db

# cat /etc/ldap.conf
host 127.0.0.1
base ou=account,dc=dajiamai,dc=com
ldap_version 3
rootbinddn cn=admin,dc=dajiamai,dc=com
pam_password md5
nss_initgroups_ignoreusers amavis,avahi,avahi-autoipd,backup,bin,clamav,clamsmtp,cyrus,daemon,dhcp,
dhcpd,dovecot,games,gdm,gnats,haldaemon,hplip,irc,klog,libuuid,list,lp,mail,man,messagebus,mysql,nb
d,newpki,news,openldap,polkituser,postfix,postgrey,proxy,pulse,root,snmp,spamass-milter,sshd,sync,sys,syslog,uucp,www-data

# cat /etc/pam.d/common-passwd
password   sufficient   pam_ldap.so
password   requisite   pam_unix.so nullok obscure md5

磁盘限额:
1、针对文件系统激活配额功能
# cat /etc/fstab:
……
/dev/sdb1 /home ext3 defaults,noatime,noexec,usrquota,grpquota 1 1           --开启个人和组的限额
或:
/dev/sdb1 /home ext3 defaults,noatime,noexec,usrquota 1 1           --开启个人限额
或:
/dev/sdb1 /home ext3 defaults,noatime,noexec,grpquota 1 1           --开启组的限额
……
# mount -o remount /home               ---或重启使配额参数生效

2、设定基于文件系统的全局参数
# touch /home/aquota.user /home/aquota.group && chmod 600 /home/aquota.user /home/aquota.group
# quotacheck -vagum                ------创建配额表aquota.user和aquota.group
# edquota -t                             ------指定延长期限(全局参数)
Filesystem             Block grace period     Inode grace period
/dev/hda3 30days 30days
3、设定个人配额
# useradd usertemplate              -----创建配额模板用户
# edquota -u usertemplate        ------为模板用户指定配额
Disk quotas for user mp3user (uid 503):
Filesystem blocks soft hard inodes soft hard
/dev/sda4 0 100000 120000 0 2000 2500
---注意:blocks和inodes指明该用户目前已经使用的块和节点数,不要改动。
# edquota -p usertemplate `ldapsearch -x -b "ou=account,dc=dajiamai,dc=com" | egrep 'uid\:' | awk '{print $2}'`                         -----为批量用户指定与模板用户相同的配额。

4、报表
# repquota -s /dev/sda4            -----显示配额文件系统上的配额使用情况。
阅读(2030) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-09-28 12:10:00

Linux网络技术论坛 http://emu.mdust.cn 欢迎Linux爱好者加入 这里有我们共同的语言 这里有我们熟悉的话题