Jamers Posted December 20, 2014 Report Share Posted December 20, 2014 在2007年前正式使用了一段时间FREEBSD,直接在正式环境中使用的,当时积累的一些脚本,最近找到了,放到网站上分享一下。以备将来有可能使用到。 2006-11-11, 09:03Samba相关资料: Samba做主域,客户端用Windows权限设定: net groupmap add rid=512 unixgroup="Domain Admins" ntgroup="Domain Admins"net groupmap add rid=513 unixgroup="Domain Users" ntgroup="Domain Users"net groupmap add rid=514 unixgroup="Domain Guests" ntgroup="Domain Guests" 查看对应帐号权限:net -U jamers rpc rights list 2007-04-05, 09:16添加用户(懒人专用):#!/usr/local/bin/bash echo $2|pw useradd $1 -c $3 -g users -s /bin/sh -m -h 0edquota -p test $1smbpasswd -a -s $1 $2$2EOF exit 0 调用方式:./adduser username password "姓名(PinYin)" Link to comment Share on other sites More sharing options...
Jamers Posted December 20, 2014 Author Report Share Posted December 20, 2014 让SSH只支持密钥文件认证: 引用用普通用户登录:cd ~mkdir .sshcd .ssh把所得到的公钥放到此目录里设文件为public_key(公钥和私钥可以用远程连接工具生成,如putty)ssh-keygen -i -f public_key >>authorized_keyschmod 644 *cd ..chown -R 用户名 .ssh 代码 ee /etc/ssh/sshd_config protocol 2MaxStartups 5:50:10X11Forwarding noMaxAuthTries 6RSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile .ssh/authorized_keysPermitRootLogin noPasswordAuthentication no#PermitEmptyPasswords no#以下两个为关键部分!ChallengeResponseAuthentication noUsePAM no /etc/rc.d/sshd restart 限制IP指定端口连接数 代码ipfw add allow all from any to me dst-port 80 setup limit src-addr 10 一网卡多IP设置引用ee /etc/rc.conf 代码ifconfig_vr0_alias0="inet 192.168.1.1 netmask 255.255.255.0"ifconfig_vr0_alias1="inet 192.168.0.1 netmask 255.255.255.0" 这里是vr0,具体要看你网卡的类型,可以使用ifconfig查看。 批量拷贝脚本,原创,哈引用绝对是懒人专用,一大批sample文件需要手工拷贝成配置文件…累吧?用这个就行了。代码#!/usr/local/bin/bashecho '================================'echo '= Batch File Copy Script ='echo '= Author:Jamers ='echo '= Date:2006-11-11 ='echo '================================'echo "Usage: $0 SourceExt TargetExt"echo ' copy *.SourceExt to *.TargetExt'echo 'Default Value: sample and ""' if [ $1! = "!" ]; thenext="sample"elseext=`echo $1 | sed 's/\.//'`fiif [ $2! = "!" ]; thenrep=""elserep=`echo $2 | sed 's/\.//'`fi#echo *.$ext,$rep#PWD=`pwd`#FILES=`ls $PWD/*.$ext`FILES=`ls *.$ext`#echo $FILESfor i in $FILES; do ( doc=`echo $i | sed "s/\.$ext/$rep/"` echo "$i ==> $doc" cp $i $doc);done 编码转换:例,有一个GB2312的程序,但是你的网站需要utf8的编码,怎么办?换程序?用这个小脚本吧,哈,一般人我还不告诉呢。代码#!/usr/local/bin/bashfor loop in `find * |grep "$1$"`; do ( if [ ! -f $loop.bak ]; then if [ -f $loop ]; then tmp=`basename $loop` tmp1=`echo $tmp | sed "s/\.gif//"` if [ $tmp = $tmp1 ]; then cp -f $loop $loop.bak iconv -c -s -f gb2312 -t utf-8 $loop.bak > $loop #echo "$loop ==>`basename $loop`"; echo "$loop" fi fi fi)done 删除指定类型文件(含子目录)代码rm `find * | grep ".bak"` Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now