Aug 17
对ssh用得比较多的同学应该知道通过建立信任关系来免除输入密码的麻烦:

在A机器上执行:

$ ssh-keygen -t rsa (各种回车)
$ ssh-copy-id -i ~/.ssh/id_rsa.pub USER@B_ip

然后在A机器上 ssh USER@B_ip 就可以免密码使用USER用户登录B机器了。

实际上第二步操作是将 A 机器该用户的公钥(id_rsa.pub)追加到B机器的 ~/.ssh/authorized_keys 文件末尾中去。

当A机器访问B时,如果B机器的sshd能够在/home/USER/.ssh/authorized_keys中找到对应的公钥,就认为A机器具有B机器的USER用户访问权限,于是就直接让A机器以USER身份登录。

但是上周在线上某台机器进行操作时却发现这一机制失效了。通过该机制,A=>B可登录,但是B=>A失败,甚至A=>A也失败(B=>B却成功)。虽然问题很奇怪,但说明问题出在A机器上。

首先是 diff 了A、B两台机器的 /etc/ssh ,发现完全相同,所以不是配置的问题。

然后查看 ssh -vv localhost
引用
....
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/felix021/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/felix021/.ssh/id_dsa
debug1: Trying private key: /home/felix021/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: Next authentication method: password

而在B机器上,we sent a public key packet, wait for reply 之后则是紧跟着"debug1: Server accepts key: pkalg ssh-rsa blen 279"。由此可以看出,是A机器的sshd不认可publickey。

至于为什么不认可,在google上查了许多,毫无头绪,直到使用类似“ssh publickey ignore debug diagnose”这样的关键词,发现这个页面,其中的第二条和第六条给出了解答:
引用
2. Debugging on the remote host by running sshd in debug mode: Run ‘/usr/sbin/sshd -d -p 2222′ on the remote host and connect to it. ’2222′ here is the port number of the sshd process you started on the remote host.

6. Check the permissions on your home directory, .ssh directory, and the authorized_keys file: If your ssh server is running with ‘StrictModes on’, it will refuse to use your public keys in the ~/.ssh/authorized_keys file. Your home directory should be writable only by you, ~/.ssh should be 700, and authorized_keys should be 600.


通过执行 /usr/sbin/sshd -d -p 2222 (在2222端口启动一个带debug输出的sshd) ,然后 ssh -vv localhost -p 2222 ,可以看到sshd输出了一行
引用
Authentication refused: bad ownership or modes for directory /home/felix021

正好与那第六条相对应,再检查一下 /home/felix021 ,其权限是其他组可写。

最终解决方案:将用户home目录的权限改为0755,登录成功。
Nov 5

吐槽牛比的支付宝 不指定

felix021 @ 2011-11-5 20:05 [IT » 软件] 评论(2) , 引用(0) , 阅读(6662) | Via 本站原创
不知道是支付宝的产品人员太牛比,还是开发人员太傻比,还是测试人员太装比呢。这尼玛玩用户啊?
Nov 2

编译安装MySQL 不指定

felix021 @ 2011-11-2 17:38 [IT » 软件] 评论(0) , 引用(0) , 阅读(4270) | Via 本站原创
$ tar zxf mysql-5.1.30.tar.gz
$ cd mysql-5.1.30
$ mkdir -p /home/fengmin/mysql
$ ./configure --prefix=/home/fengmin/mysql --with-plugins=all --with-pthread --with-charset=utf8 --with-extra-charsets=all
$ make -j4 &> make.log
$ make install
$ cd /home/fengmin/mysql
$ mkdir data
$ ./bin/mysql_install_db --datadir=/home/fengmin/mysql/data/
$ cp ./share/mysql/my-small.cnf my.cnf
$ vi my.cnf #修改各种配置
$ ./bin/mysqld_safe --defaults-file=/home/fengmin/mysql/my.cnf & #启动server
$ ./bin/mysqladmin -u root password 'newpassword' -h 127.0.0.1 -P 3306 #修改root密码

$ ./bin/mysql -h127.0.0.1 -P 3306 -u root -pnewpassword #连接mysql

$ ./bin/mysqladmin -h 127.0.0.1 -P 3306 -u root -pnewpassword shutdown #关闭server
Oct 23

winrar优化 不指定

felix021 @ 2011-10-23 18:03 [IT » 软件] 评论(0) , 引用(0) , 阅读(5585) | Via 本站原创
选项->设置->压缩->创建默认配置

[常规]
~压缩文件格式:
zip (方便分享,windows默认支持)

~压缩方式:
较好

[文件]
~ 要排除的文件:
*\Thumbs.db

~ 不压缩直接存储的文件
*.jpg *.jpeg *.png *.avi *.wmv *.rmvb *.rm *.gif *.mp4 *.mkv *.zip *.rar *.gz *.bz2 *.mp3 *.wma
Aug 24

rsync的坑 不指定

felix021 @ 2011-8-24 18:41 [IT » 软件] 评论(0) , 引用(0) , 阅读(7186) | Via 本站原创
rsync是个好东西,同步文件很方便,等啥时候有空了,可以考虑把内核提供的inotify功能结合起来,搞一个实时文件同步的应用 :D

回归主题,说说这个坑,线上的机器用rsync来进行文件的同步。
$ rsync -az --delete /home/user/files/ user@remote_host:/home/user/files/
user@remote_host's password:
TERM environment variable not set.
protocol version mismatch -- is your shell clean?
(see the rsync man page for an explanation)
rsync error: protocol incompatibility (code 2) at compat.c(174) [sender=3.0.8]


从昨天到今天这个问题一直出现,不管是2.6.8还是最新的3.0.8,看了N个使用例子,最后结果都是这样。Boluor同学的建议是配置信任关系(ssh-keygen -t rsa; ssh-copy-id user@remote_host),但是这样只是不需要输入密码,并没有解决问题。

于是RTFW,Google了一下,发现在 http://ss64.com/bash/rsync.html 的DIAGNOSTIC 一节有说明, .bashrc 等启动脚本的任何输出,都会影响rsync通过ssh同步时的数据流,导致协议不匹配。

以这个命令为例:

$ ssh user@remote_host /bin/true > out.txt

实际上所有的动作是

1.  ssh 与 remote_host 的 sshd 交互
2. sshd fork出一个 user shell(一般是/bin/bash)
3. /bin/bash 载入 $USER/.bash_profile
4. .bash_profile一般会载入.bashrc
5. /bin/bash 执行/bin/true 并重定向stdin到out.txt

正常情况下,out.txt应该是一个空文件。如果在这个过程中有任何输出(比如我当时的.bashrc有一个echo),就会导致rsync在执行过程中的数据有额外的GARBAGE,出现问题。

OVER.
Jun 24
使用以下脚本来编译安装,需要把安装文件下载到 [ROOT]/src/ 下。

目录结构:

[ROOT]
    /src
        /php-5.2.17.tar.bz2
        ...
    /httpd
    /php
    /fcgi-bin

#!/bin/bash

set -x

ROOT="/home/felix021/lamp"
ROOT_E=${ROOT//\//\\\/}        # escape for sed, / => \/

WWWROOT="/home/felix021/lamp/wwwroot"
WWWROOT_E=${WWWROOT//\//\\\/}  # escape for sed, / => \/

HTTPD_PORT=80

FCGI_CHILDREN=4
FCGI_MAX_REQUESTS=1000

# 下载好的源码文件
fastcgi="mod_fastcgi-2.4.6"        #.tar.gz
httpd="httpd-2.2.17"                #.tar.bz2
php="php-5.2.17"                    #.tar.bz2
eaccelerator="eaccelerator-0.9.6.1" #.tar.bz2

SRCROOT=${ROOT}/src
mkdir -p $ROOT/{httpd,php,fcgi-bin}
mkdir -p $WWWROOT

# fcgi-bin (for apache + mod_fastcgi) 
# 创建这个脚本可以用来包装php-cgi,可以控制启动的FCGI进程数量
if [ ! -e "${ROOT}/fcgi-bin/php.cgi" ]; then
    > ${ROOT}/fcgi-bin/php.cgi echo "#!/bin/sh
# Shell Script To Run PHP5 using mod_fastcgi under Apache 2.x

### Set PATH ###
PHP_CGI=${ROOT}/php/bin/php-cgi
PHP_FCGI_CHILDREN=${FCGI_CHILDREN}
PHP_FCGI_MAX_REQUESTS=${FCGI_MAX_REQUESTS}

### no editing below ###
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS
exec \$PHP_CGI
"
    chmod +x ${ROOT}/fcgi-bin/php.cgi
fi

# php
cd $SRCROOT
if [ ! -d "${php}" ]; then
    tar jxf ${php}.tar.bz2
    cd $php
    ./configure --prefix=${ROOT}/php --with-gd --with-iconv \
        --with-curl --enable-fastcgi --with-openssl --enable-mbstring  #有需要的话自己再增加一些模块吧
    echo Making... Please wait. "tail -f `pwd`/php.log" to view make output.
    make -j4 &> php.log
    make install
    cp php.init-dist ${ROOT}/php/lib/php.ini
fi

# eaccelerator
if [ ! -d "${eaccelerator}" ]; then
    tar jxf ${eaccelerator}.tar.bz2
    cd $eaccelerator
    export PHP_PREFIX=${ROOT}/php
    $PHP_PREFIX/bin/phpize
    ./configure --enable-eaccelerator=shared \
        --with-php-config=$PHP_PREFIX/bin/php-config
    make -j4 &> eaccelerator.log
    make install
    echo Please edit php.ini to enable eaccelerator.so
fi


# httpd
cd $SRCROOT
if [ ! -d "${httpd}" ]; then
    tar jxf ${httpd}.tar.bz2
    cd ${httpd}
    ./configure --prefix=${ROOT}/httpd --enable-rewrite
    echo Making... Please wait. "tail -f `pwd`/httpd.log" to view make output.
    make -j4 &> httpd.log
    make install

    conf_path="${ROOT}/httpd/conf/httpd.conf"

    # 下面这段sed脚本是把端口、DocRoot替换了,并允许目录下使用.htaccess来配置url rewrite
    sed -i $conf_path \
        -e "s/^Listen 80$/Listen ${HTTPD_PORT}/" \
        -e "s/\/.*\/htdocs\>/${WWWROOT_E}/" \
        -e "s/AllowOverride None/AllowOverride FileInfo/"

    fcgi_path="${ROOT}/fcgi-bin/"

    # 在配置中加入FastCgi相关的内容
    echo "
LoadModule fastcgi_module modules/mod_fastcgi.so

FastCgiServer \"${fcgi_path}php.cgi\"
AddHandler php-fastcgi .php

ScriptAlias /fcgi-bin/ \"${fcgi_path}\"
Action php-fastcgi "/fcgi-bin/php.cgi"
AddType application/x-httpd-php .php

<Directory \"${fcgi_path}\">
    SetHandler fastcgi-script
    Options FollowSymlinks +ExecCGI
    Order Allow,Deny
    Allow from All
</Directory>
"  >> $conf_path

fi

# mod_fastcgi for httpd
cd $SRCROOT
if [ ! -d "${fastcgi}" ]; then
    tar zxf ${fastcgi}.tar.gz
    cd ${fastcgi}
    cp Makefile.AP2 Makefile
    make top_dir=${ROOT}/httpd -j4 &> fastcgi.log
    make top_dir=${ROOT}/httpd install
fi

echo Done. Please run "${ROOT}/httpd/bin/apachectl start"
Feb 23

Ubuntu下架设简易svn服务器 不指定

felix021 @ 2011-2-23 16:13 [IT » 软件] 评论(1) , 引用(0) , 阅读(7169) | Via 本站原创
$ sudo apt-get install subversion
$ mkdir ~/svn/repo
$ cd ~/svn
$ svnadmin create repo

#配置
$ vi repo/conf/svnserve.conf
把一下几行前面的#去掉(行首不能有空格
anon-access = read
auth-access = write
password-db = passwd
authz-db = authz
realm = Repository
保存
$ vi repo/conf/passwd
格式很简单,在[users]后面,一个用户一行,格式为
用户名 = 密码
比如  felix021 = 123456
保存
$ vi repo/conf/authz
控制各个用户的权限,比较繁琐,最简单的是在[aliases]这一节【前面】加上这两行
[/]
*=rw
保存。

#运行服务
$ svnserve --daemon --root /home/feilx021/svn/
//可以在svn目录下创建多个项目的repository。

#--分割线--
#客户端
$ svn chechout svn://server_name/repo
Checked out revision 0.
Feb 3

让电脑更适合父母使用 不指定

felix021 @ 2011-2-3 13:26 [IT » 软件] 评论(3) , 引用(0) , 阅读(7037) | Via 本站原创
我爸妈用的这台笔记本是09年6月20号左右在广埠屯买的。Acer 4736ZG, T4200, 2G, 320G, G105M, 14'' LCD。配置性能是很够用了,不过一年半多了,电脑挺乱的,所以这两天花了不少时间整理、调整。

1. 操作系统
还是用Win7了,毕竟微软以后就是这种风格,让父母习惯了会比较好。而且界面华丽,看着也比较舒服。

2. 软件
(1) 浏览器,搜狗的。360废品当然不能装;虽然我喜欢Chrome,但是有些网站在非IE浏览器上就不正常,对于非Geek的父母还是用搜狗吧。
(2) 杀毒,AVG 2011。免费杀软,基本不影响性能,而且不打扰使用,挺好的。
(3) 输入法,QQ拼音,比较不打扰,而且手写、笔画输入功能比搜狗的方便。
(4) 其他软件,QQ影音、QQ直播、QQ音乐、PPS、WinRAR、Office、飞信、迅雷。。。还装了个金山打字通,让父母练习打字。

3. 可用性
(1) 父母有远视了,所以字体界面一定得看得清楚。
--) DPI,右击桌面,分辨率,点击“放大或缩小文本和其他项目”,选择125%,或者在左边点击“设置自定义文本大小(DPI)”,我选择的是110%,看起来挺好。
--) 鼠标,改成 Aero(特大) 方案
--) 常用软件的字体,比如输入法字体、歌词字体都调大
--) 在搜狗浏览器的右下角把120%缩放设置成默认。
(2) 安装StarDock的fences,把桌面图标分类清楚,并把常用软件图标放在桌面上。
(3) 把我的文档、桌面、音乐、视频、下载等文件夹的位置更改到D、E盘,避免以后重装的数据丢失
(4) 输入法开启模糊音,这样父母打字的时候困惑少一点。
(5) 开机启动程序,把没用的全都关掉,但是把QQ留下。
(6) 把hao123之类导航设置为上网主页。

4. 其他
(1) 最好是有一个无线路由器,设置好密码,这样父母上网就很方便了。
(2) 把QIYI.com的快捷方式添加到收藏夹以及桌面,方便看电影、电视剧。
(3) 建立一个PPPoE连接,把快捷方式放在桌面上,万一父母更换了上网地点和方式,不要教他们一步步地建立拨号连接,只要打开填入用户名和密码就行了。

还有没有更多建议,一起来补充吧。
分页: 3/12 第一页 上页 1 2 3 4 5 6 7 8 9 10 下页 最后页 [ 显示模式: 摘要 | 列表 ]