close

 

 chpasswd安裝筆記

                                                多啦A2008/12/03             amon0626@gmail.com

        在過去有開放系統服務ex. proxy, http等的Linux平台上有做驗證管理的相信大家都有一個相同的困擾,就是沒有辦法讓使用者自由地修改密碼。每當需要換密碼時總是要請user帶著證明文件來找系統管理者很蠢地passwd username, 輸入完一次以後又再問你一次,就算人家user不煩總有一天身為管理者的你也會被user煩到往生那該怎麼做哩?...


        SARG的作者用它無聊的時間寫了一支chpasswdcgi程式讓我們的user可用web介面的方式去更改密碼,只要密碼檔格式是

 

account:passwd

 

像是我們apachehtpasswd以及proxy這種都可以支援,如果要讓使用者更改/etc/passwd /etc/shadow就沒解了嗎?免擔心啦~

同樣一位作者還有寫另外一支叫做chetcpasswd在權限制上有提升且比較嚴格(但用web開放出來就是比較危險啦),下回再討論

 

---------------------------------------------------正式開始-----------------------------------------------------------


程式由此下載:

http://sourceforge.net/project/downloading.php?groupname=orsochpasswd&filename=chpasswd-2.2.3.tar.gz&use_mirror=jaist

前置動作:

1.      安裝make(沒有它就不能編譯啦)

2.      安裝patch(加上patch用的)

3.      設定好apache上的cgi-bin目錄

編譯可下的參數:

configure options: 
                                   設定檔的放置位置
                                   --prefix=where the config file is
                                                             default: /usr/local/etc/chpasswd
 
                                   使用的語言
                   --enable-language=English, Chinese, Chinese_big5, 
                                                                            Czech, Dutch, French, German, 
                                                    Hungarian, Indonesian, Italian, 
                                                                            Latvian, Polish, Portuguese, Romanian,
                                                                            Russian1251, Japanese, Serbian,                                                        Spanish, Swedish, Turkish,
                                                                            default: English
 
                                   cgi目錄的位置
                   --enable-cgidir=where your cgi-bin is 
                                                             default: /usr/local/etc/httpd/cgi-bin
 
以我本身位置為例:
1.      ./configure --prefix=/etc/chpasswd  --enable-language=Chinese_big5 --enable-cgidir=/var/www/cgi-bin
2.      make
?怎麼會出現error
chpasswd.c:287: error: static declaration of 'htoi' follows non-static declaration
chpasswd.c:269: error: previous implicit declaration of 'htoi' was here
原來這是已知的bug,後來有釋出修復的patch
由此下載:
http://sarg.sourceforge.net/htoi.patch
將此patch檔複製到安裝目錄
然後
patch -p0 < saved.patch
make
大成功!!!
3.      make install
4.      make clean
安裝完成!!!
 
以我這邊的例子來說,設定檔是在/etc/chpasswd/下的chpasswd.conf以下是他的設定檔,就看在設定項沒那麼多的份上位大家服務附上翻譯(其實沒有很複雜啦,只想充個字數)
   chpasswd.conf
  
   密碼檔放在哪裡(注意!!非常重要,同時也要注意密碼檔的權限設定)
   TAG: passwd_file
        Where the password file is.
 
   允許可存取的ip or 網段檔案的路徑(意思就是你可以寫一支檔案裡面是你限制使用者存取的網段或是IP)
   TAG: ip_auth
        File with IP address or subnet address allowed to use.
             Eg.: 192.168.82.10 - only this IP will use
                  192.168.82.0  - IP's from 1 to 255   
                  192.168.0.0   - ...
                  192.0.0.0     - ...
                  0.0.0.0       - allow everybody. A bad choice...  
 
   TAG: header
        Especify the header for html page.
 
  最小密碼長度(最少設個6~8)
   TAG: minimum_length
        Especify the password minimum lenght.
  最大密碼長度(隨便設)
   TAG: maximum_length
        Especify the password maximum lenght.
  最少要有幾個字元(就是一段密碼中最少要有幾個字母啦)
   TAG: minimum_char
        Force minimum characters (a-z, A-Z) on the new password.
  
   最少要有幾個數字(一段密碼中最少要有幾個數字)
   TAG: minimum_num
        Force minimum numbers (0-9) on the new password.
 
   最少要有幾個特殊字元(例如:@,%,&,空白…)
   TAG: minimum_spec
        Force minimum special characters (keyboard) on the new password.
  
   chpasswd log檔放置的位置,當有使用者使用chpasswd更改密碼時同時會          將此行為紀錄在log檔裡面(注意權限設定!!!)
   TAG: enable_log
        chpasswd will write a log from users request
         to the filename specified here.
         By default enable_log is disabled.
  
   是否要在log檔裡面使用者的密碼以明文顯示(注意,請管理者衡量)
   TAG: show_pwd
        Show new pwd in clear text on log.
 
P.S. passwd_fileip_auth 兩支檔案必須能夠讓httpuser可讀可寫,像ubuntu server上的apache的執行userwww-data
 
設定好後就可以依你設定好的路徑去存取喔
以我這邊的例子:
http://xxx.xxx.tw/cgi-bin/chpasswd.cgi
1 
圖一. chpasswd.cgi更改密碼的介面
更改密碼成功後會出現以下頁面(有點陽春,還不能回首頁勒~迷之聲:那麼厲害你不會自己寫喔~)
2 
圖二. 修改密碼成功訊息
最後要大家注意的是請斟酌使用此程式,由於密碼檔必須要讓httpuser去存取所以多少都會有些風險在喔,建議是僅提供內部網路的使用者去使用啦~
arrow
arrow
    全站熱搜

    amon0626 發表在 痞客邦 留言(0) 人氣()