Archive for category linux
vsftpd不能chroot的问题的问题
前两天在公司的服务器上配了一个ftp服务器,用的是vsftpd。
今天同事和我说不能创建目录也不能上传文件。
表现为使用mkdir提示:
550 Create directory operation failed.
使用put提示:
553 Could not create file.
登上去一看,果然如此。只有ls命令还能用,于是ls一下,看看有什么文件、目录之类没有,发现没有任何文件存在嘛,于是ssh远程登录上去创建一个文件夹,但是在ftp客户端中ls还是没有显示出来。据此猜测应该是ftp服务器没有改变到用户目录去。
在google上搜索之,找到一个vsftpd的配置说明。http://vsftpd.beasts.org/vsftpd_conf.html
有此段:
chroot_local_user
If set to YES, local users will be (by default) placed in a chroot() jail in their home directory after login. Warning: This option has security implications, especially if the users have upload permission, or shell access. Only enable if you know what you are doing. Note that these security implications are not vsftpd specific. They apply to all FTP daemons which offer to put local users in chroot() jails.
Default: NO
配上之后重启服务器,登录,提示 vsftpd 500 OOPS: chroot
在google之找到http://www.linuxquestions.org/questions/linux-networking-3/ftp-500-oops-cannot-change-directory-432558/
于是知道是selinux的问题,它有一个叫做”Allow ftp to read/write in the user home directories” 的选项。使用如下命令
/usr/sbin/setsebool -P ftp_home_dir 1
打开选项,重启服务器,登录,一切ok了。
感谢google,感谢…你懂的。
新浪微博使用curl
-
SINAUSER=username
-
SINAPASS=password
-
SINACOOKIE=/path/store/sina/cookie
-
curl -d "service=miniblog&entry=miniblog&username=${SINAUSER}&password=${SINAPASS}&url=http://t.sina.com.cn/ajaxlogin.php" "http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.3.0)" -e "http://t.sina.com.cn/" -c ${SINACOOKIE} -s >> /dev/null
-
curl -d "content=${STATUS}&pic=&from=myprofile" "http://t.sina.com.cn/mblog/publish.php" -e "http://t.sina.com.cn/jinuljt" -b ${SINACOOKIE}
默认google dns 服务器
Local DNS Cache for Faster Browsing
推荐上文。说的是在本机建立一个dns缓存机制,每次dns请求先尝试找找本机的缓存。不过对于个人计算机而言有意义有多大?不管他,反正我装了。不过我关心的不再此处,而是以下。
通过编辑 /etc/dhcp3/dhclient.conf 增加
prepend domain-name-servers 8.8.8.8;
prepend domain-name-servers 8.8.4.4;
两个配置项使得每次dhcp之后都会默认增加google 的两个dns服务器。
安了ubuntu 9.10后遇到的问题
emacs 23 切换输入法不能。设置 LC_CTYPE=”zh_CN.UTF-8″
未装中文语言包,还是不行。。。
x模式的话使用emacs自带的输入法。console模式可以使用输入法。
xterm中alt键不能作为meta。 在~/.Xdefaults 加入 XTerm*VT100.metaSendsEscape: true
freemind的中文显示问题。字体问题,修改freemind字体为WenQuanYi Zen Hei。
linux通过Blackberry上网
我的设备:blackberry 8700
我的运营商:中国移动
文件一:/etc/ppp/peers/cmwap
noauth
user “”
password “”
defaultroute
usepeerdns
noipdefault
nodetach
novj
nodeflate
nobsdcomp
noaccomp
nocrtscts
nomultilink
nopcomp
nomagic
passive
ipcp-restart 7
ipcp-accept-local
ipcp-accept-remote
lcp-echo-interval 0
lcp-echo-failure 999
mtu 1492
debug
pty “/usr/sbin/pppob”
文件二:/etc/chatscripts/cmwap.chat
OK ‘AT+CGDCONT=1,”IP”,”cmwap”‘
OK ‘ATDT*99#’
命令:sudo pppd call cmwap
ps:显然将/etc/chatscripts/cmwap.chat文件中的cmwap改为cmnet,就可以上cmnet了。
pps:显然文件名与 call 的文件名是相关的,随便改。
同时更新renren与twitter
同时更新 renren与twitter状态的bash脚本。
对于renren网,使用curl模拟登录与提交。
之与twiiter则使用curl直接调用其api提交。
-
#!/bin/bash
-
CURL=/usr/bin/curl
-
COOKIE=/tmp/renren.cookie
-
STATUS=$1
-
RRUSER=renren username
-
RRPASS=renren password
-
TWUSER=twitter username
-
TWPASS=twitter password
-
${CURL} -d "email=${RRUSER}&password=${RRPASS}" "http://passport.renren.com/PLogin.do" -c ${COOKIE} -L -s >> /dev/null
-
RESPONSE=`${CURL} -d "c=${STATUS}&raw=${STATUS}&isAtHome=1" "http://status.renren.com/doing/update.do?" -e "http://status.renren.com/ajaxproxy.htm" -b ${COOKIE} -L -s`
-
#echo ${RESPONSE}
-
echo "Update renren.com"
-
if echo ${RESPONSE}|grep -q "updateStatusId"
-
then
-
echo "successful"
-
else
-
echo "fail"
-
fi
-
-
RESPONSE=`${CURL} -u "${TWUSER}:${TWPASS}" -d status="${STATUS}" https://twitter.com/statuses/update.xml -s`
-
#echo ${RESPONSE}
-
echo "Update twitter.com"
-
if echo ${RESPONSE}|grep -q "status"
-
then
-
echo "successful"
-
else
-
echo "fail"
-
fi
inotifywait + rsync 同步源代码
-
#!/bin/sh
-
SRC_DIR=$1
-
DST_DIR=$2
-
#etc:rsync_moniter /home/user/cpp_src user@pc_name:/home/user/
-
echo "if there file modify,create,delete happens on \"$1\" ,it will auto rsync with \"$2\""
-
inotifywait -mrq –exclude ".*(swp|swx|~)" -e modify,create,delete $SRC_DIR|
-
while read line
-
do
-
rsync -a $SRC_DIR $DST_DIR
-
done
一般在本机上写代码,需要在rhel5上面编译,跑程序。
懒得复制来复制去的(- -b,代码相当ugly,debug比较多)。
inotifywait监控文件增删改,然后调用rsync同步文件。
openssh-client 支持socks4a代理
买了vps之后就建了一个vpn,可是很明显,vpn不能够满足我的要求。
所有的数据都从vpn走的话,是很方便,不用分辨哪些网站不能走正常途径。可是访问国内网站就比较慢了。所以还是选择使用ssh隧道来做到动态选择。
唯一的问题在于ssh隧道支持不支持socks4a,那么dns解析只能在本地进行。而dns总是会得到一些fake 信息,也挺烦人的。
万幸,搜到此文 Patch for SOCKS4A in OpenSsh ,于是换了ssh客户端。
privoxy socks4a + ssh tunnel 搞定一切代理,过滤。
抛弃gds换用beagle
使用s3curl备份blog
对于备份blog我已经有很长时间的念想了。
把数据库备份在本机这种烂事我不想干……
每日发邮件备份?这个我是最先想到的,不过挺麻烦的,没有仔细整。
今日看blog的时候真好有人说的amazon s3服务,便宜,使用简单,于是一试。
期间也遇到一些问题参考了该文。
写了一个脚本,在cron里让丫每天执行一次备份,从此省心了。
看了一下,目前我的blog db压缩后只有144kb,s3的服务又如此廉价,我很放心。

Recent Comments