聚會時間公告: 11月份聚會為11月15號星期六下午兩點在MocaMona / 講者:shawn Topic: Hello BIOS: EFI, an opensource firmware framework

九月 2, 2008
» 【Bug】halt: Unable to iterate IDE devices: NO such file or directory

凍仁在灌了無數台 Server 終於踢到鐵板啦,沒想到 Mr.曾 的準系統灌完 Ubuntu Server 8.041 後會無法正常關機,更冒出 halt: Unable to iterate IDE devices: NO such file or directory 的錯誤訊息,Google 大神說:只要小小改幾個字就能 K.O. 他啦 :p

修改前

jonny@ubuntu:~$ sudo vi /etc/init.d/halt
......

# See if we need to cut the power.
if [ "$INIT_HALT" = "POWEROFF" ] && [ -x /etc/init.d/ups-monitor ]
then
    /etc/init.d/ups-monitor poweroff
fi


修改後
jonny@ubuntu:~$ sudo vi /etc/init.d/halt
...

# See if we need to cut the power.
if [ "$INIT_HALT" = "POWEROFF" -a -x /etc/init.d/ups-monitor ]
then
    /etc/init.d/ups-monitor poweroff
fi


之後在 kernel 後加上 acpi=force 參數
jonny@ubuntu:~$ sudo vi /boot/grub/menu.lst
...
title         Ubuntu 8.04.1, kernel 2.6.24-19-server
root         (hd0,0)
kernel     /boot/vmlinuz-2.6.24-19-server root=UUID=6fc5208a-da63-4108- 9af5-21e809c3b5cd ro quiet splash
acpi=force
initrd       /boot/initrd.img-2.6.24-19-server


關機並測試
jonny@ubuntu:~$ sudo shutdown -h now

ps:除了 shutdown 還有 halt 、poweroff .. 等關機指令可用 :P


資料來源:
LinuxSir.Org:Ubuntu 7 無法關機

八月 22, 2008
» 【Server】DNS Server @ Static ADSL

Domain Name System (DNS),中譯網域名稱系統 記得在竹高上計概時就已經有聽過這一名詞。摸到才知道自己沒學好,真的覺得多出來走走會學的比綁在學校 k 理論還來的多:P

Environment (環境)


Operation-System:Ubuntu Server 8.041
Deb:bind9 (DNS)
jonny@ubuntu:~$ sudo apt-get install bind9

Hinet 網域註冊:
DNS Server Name:www.hjz.com.tw
IP Address:122.xxx.xxx.41

DNS Server Name:dns.hjz.com.tw
IP Address:122.xxx.xxx.41


Server Configure (伺服器設定)


1. 加入正反解設定:named.conf 會指出 Server 管轄的區域(Zone)名稱及相關檔案。於 include "/etc/bind/named.conf.local"; 上方加入預新增的設定
jonny@ubuntu:~$ sudo vi /etc/bind/named.conf
...
//增加正解區域(Zone)
zone "hjz.com.tw" {
    type master;
    file "/etc/bind/db.hjz";
};

//增加反解區域(Zone)
zone "205.117.122.in-addr.arpa" {
    type master;
    file "/etc/bind/db.205.117.122";
};

include "/etc/bind/named.conf.local";


2. 修改 Bind 參數
  1. 備份原始參數
    jonny@ubuntu:/etc/bind$ sudo cp named.conf.options named.conf.options.bak

  2. 更新參數
    jonny@ubuntu:/etc/bind$ sudo vi named,conf.options
    options {

        directory "/var/cache/bind";
        forwarders {
            168.95.1.1; 139.175.10.20; 203.133.1.6;
        };
        allow-query { any; };
        allow-transfer { none; };

    };


3. 建立正解區域設定檔
jonny@ubuntu:/etc/bind$ sudo vi db.hjz
; BIND reverse data file for local loopback interface

$TTL 604800
@       IN   SOA  
hjz.com.tw. dns.hjz.com.tw. (
        1     ; Serial
        604800     ; Refresh
        86400       ; Retry
        2419200    ; Expire
        604800 )    ; Negative Cache TTL
;

@       IN     NS     dns.hjz.com.tw.
@       IN     NS     www.hjz.com.tw.
@       IN     MX 10   122.xxx.xxx.41
@       IN     A     122.xxx.xxx.41
www   IN     A     122.xxx.xxx.41


4. 3. 建立反解區域設定檔
jonny@ubuntu:/etc/bind$ sudo vi db.xxx.xxx.122
; BIND reverse data file for local loopback interface

$TTL 604800
@       IN   SOA  
@     root.dns.hjz.com.tw. (
        1     ; Serial
        604800     ; Refresh
        86400       ; Retry
        2419200    ; Expire
        604800 )    ; Negative Cache TTL
;

@       IN     NS     dns.hjz.com.tw.
@       IN     NS     www.hjz.com.tw.
41     IN     PTR     dns.hjz.com.tw.
41     IN     PTR     www.hjz.com.tw.


5. 重開 DNS Server
jonny@ubuntu:~$ sudo /etc/init.d/bind9 restart
[sudo] password for jonny:
* Stopping domain name service... bind         [ OK ]
* Starting domain name service... bind          [ OK ]


資料來源:
毓林園地:[ubuntu]設定 DNS

延伸閱讀:
VBird:DNS 伺服器

八月 9, 2008
» 【Network】PPPoE 撥接上網(ADSL)

雖說在 Ubuntu Desktop 的網路設定裡已經有 PPPoE 撥接上網 圖形化的設定介面,可凍仁還是比較習慣透過指令的方式來設定,一來可以通行各家版本,二來可以在開機時(未登錄前)自動撥號。有些人會說 Windows 開機比 Ubuntu 快,可進到 operating system 還得 load 半天.. 不過這種東西很難界定就是了:P

1. 在 Ubuntu → 附屬應用程式 → 終端機 執行以下指令

jonny@ubuntu:~$ sudo pppoeconf


2. 搜尋所有的網路卡 → 是 (yes)


3. 偵測中


4. 確定修改 → 是 (yes)


5. 常用選項 → 是 (yes)


6. 輸入使用者名稱:中華電信一般使用者請輸入 xxx@hinet.het
;使用 固定 IP 架站者請輸入 xxx@ip.hinet.net,等 PPPoE 設定完成再修改固定IP


7. 輸入密碼


8. 使用配發 DNS:使用 ISP 提供的 DNS → 是 (yes)


9. 限制 MSS(最大分段大小) 障礙 → 是 (yes)


10. 完成:啟動連線 → 是 (yes)


11. 啟動連線 → 是 (yes)


接下來在終端機會顯示 PPPoE 撥接成功訊息
Plugin rp-pppoe.so loaded


基本操作


中斷連線
jonny@ubuntu:~$ sudo poff -a


手動連線
jonny@ubuntu:~$ sudo pon dsl-provider



延伸閱讀:
OSWikiHK:使用 PPPoEConf 連接 Internet?
【Network】修改固定IP
【Network】網路設定 - DNS篇

六月 16, 2008
» 【Command】各種壓縮與解壓縮指令

.tar
打包:tar cvf FileName.tar DirName
解包: tar xvf FileName.tar

.gz
壓縮:gzip FileName
解壓1:gunzip FileName.gz
解壓2:gzip -d FileName.gz


.tar.gz
壓縮:tar zcvf FileName.tar.gz DirName
解壓:tar zxvf FileName.tar.gz

.bz2
壓縮: bzip2 -z FileName
解壓1:bzip2 -d FileName.bz2
解壓2:bunzip2 FileName.bz2


.tar.bz2
壓縮:tar jcvf FileName.tar.bz2 DirName
解壓:tar jxvf FileName.tar.bz2

.bz
壓縮:unkown
解壓1:bzip2 -d FileName.bz
解壓2:bunzip2 FileName.bz

.tar.bz
壓縮:unkown
解壓:tar jxvf FileName.tar.bz

.Z
壓縮:compress FileName
解壓:uncompress FileName.Z

.tar.Z
壓縮:tar Zcvf FileName.tar.Z DirName
解壓:tar Zxvf FileName.tar.Z

.tgz
壓縮:unkown
解壓:tar zxvf FileName.tgz

.tar.tgz
壓縮:tar zcvf FileName.tar.tgz FileName
解壓:tar zxvf FileName.tar.tgz

.zip
壓縮:zip FileName.zip DirName
解壓:unzip FileName.zip

.rar
壓縮:rar e FileName.rar rar a FileName.rar
解壓:rar a FileName.rar rar e FileName.rar

.lha
壓縮:lha -a FileName.lha FileName
解壓:lha -e FileName.lha

資料來源:
EvoTalk - Unix下常用壓縮格式的壓縮與解壓縮方法

五月 3, 2008
» 【Quota】磁碟配額(Disk Quota)

凍仁幫各個社團開帳號時,除了關閉 ssh 服務之外,還想限制各帳號的磁碟空間,以免被資源被濫用。在鳥哥得知有 quota 可限制空間,可凍仁卻有那麼點不懂,索性跟老闆借了 Novell Suse Linux Enterprise Server 9 管理手冊 一書才搞定。其中 usrquota 為單獨使用者;grpquota 為針對使用者群組設定配額。By the way, quota 除了限制磁碟空間大小之外,還可限制建立檔案的inode(數量)。

實作磁碟配額步驟:
1. 安裝 quota 套件。

jonny@ubuntu:~$ sudo apt-get install quota


2. 修改 /etc/fstab 檔案並選擇預設定 Quota 的檔案系統。
jonny@ubuntu:~$ sudo vi /etc/fstab
#裝置    掛載點  檔案系統格式  mount選項
/dev/sda7  /home  ext3  defaults,usrquota,grpquota


3. 重新掛載檔案系統:加入 usrquota 與 grpquota 後,需重新掛載才有效。
jonny@ubuntu:~$ sudo mount -o remount /home


4. 初始化 Quota 資料庫:quota 會藉由 Database(資料庫) 紀錄使用者或群組的使用情況,首先得使用 quotacheck 檢查配額的檔案系統及建立磁碟用量表格。(下方以 home 為例)
jonny@ubuntu:~$ sudo qoutacheck -cmug /home
# c:建立 quota 資料庫 | u:檢查使用者配額 | g:檢查群組配額

執行完會產生 aquota.user(使用者 Quota 資料庫)、aquota.qroup(群組 Quota 資料庫)。
jonny@ubuntu:~$ /home$ ls -l /home/aquota.*
-rw------- 1 root root 8192 2008-03-26 18:46 /home/aquota.group
-rw------- 1 root root 7168 2008-03-26 18:46 /home/aquota.user


5. 啟動 Quota Deamon:
jonny@ubuntu:~$ sudo quotaon -av


6. 編輯使用者或群組 Quota 規則
# 設定使用者磁碟配額
jonny@ubuntu:~$ sudo edquota -u UserName

# 設定群組磁碟配額
jonny@ubuntu:~$ sudo edquota -g GroupName

接著會進入 quota 編輯模式..
GNU nano 2.0.6 檔案: /tmp//EdP.aD0puo9

Disk quotas for user spa (uid 1004):
 Filesystem  blocks  soft  hard inodes soft hard
 /dev/sda7   24 100000 102400   7  0  0


^G 求助 ^O 寫入 ^R 讀檔 ^Y 上頁 ^K 剪下文字 ^C 游標位置
^X 離開 ^J 對齊 ^W 搜尋 ^V 下頁 ^U UnCut Text^T 拼字檢查

 第1欄(Filesystem):啟用 quota 的檔案系統名增
 第2欄(blocks):使用者已使用的區塊數量
 第3欄(soft):非強制性的磁碟空間限制 /* 單位:k */
 第4欄(hard):強制性的磁碟空間限制 /* 單位:k */
 第5欄(inodes):使用者已使用的檔案數目
 第6欄(soft):非強制性的 inode 限制
 第7欄(hard):強制性的 inode 限制



套用某個使用者的規則
jonny@ubuntu:~$ sudo edquota -p <被參考的使用者> user1,user2 ..

確認使用者配額
jonny@ubuntu:~$ sudo quota UserName

確認群組配額
jonny@ubuntu:~$ sudo quota -g GroupName




檢視單一目錄磁碟配額報告
jonny@ubuntu:~$ sudo repquota /home

檢視所有配額中的磁碟用量報告
jonny@ubuntu:~$ sudo repquota -aug


延伸閱讀:
【Quota】修改寬限時間(grace time)

資料來源:
Novell Suse Linux Enterprise Server 9 管理手冊 - ch7.6
鳥哥 - Linux 磁碟配額 (Quota)

四月 21, 2008
» 【Editer】vim 設定檔 @ B2D

凍仁管 B2D Linux Server 時發現裡面內建的 vim 設定檔做的很棒。如懶的自行設定的玩家不妨用用 B2D 的設定唄。

ssh 遠端連接 B2D Linux Server 截圖



2008-04-19


凍仁在 Ubuntu 7.10 實作中遇到些問題,並不是直接下載完放進家目錄底下就可用囉,以下是凍仁的 vi 改造筆記
  1. 安裝 vim
    jonny@ubuntu:~$ sudo apt-get install vim

  2. 切換至家目錄下
    jonny@ubuntu:~$ cd ~

  3. 下載 B2D 的 vim 設定檔 .vimrc
    jonny@ubuntu:~$ wget http://140.127.138.72/jonny/download/config/.vimrc

  4. 將環境改為 utf8 格式 /* B2D 預設為 big5 */
    32 set enc=big5 utf8

  5. 最後補上凍仁之前愛用的設定 → 【Editer】vimrc - vi 環境設定

2008-04-21


如要在 Trixbox 使用請先安裝 vim。注意!請依照 Server 種類安裝(以下為PC i386)
jonny@centos:~$ sudo yum install vim-X11.i386



jonny@ubuntu:~$ vi .vimrc
" Configuration file for vim

" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible " Use Vim defaults instead of 100% vi compatibility
set backspace=indent,eol,start " more powerful backspacing

" Now we set some defaults for the editor
set autoindent " always set autoindenting on
set textwidth=0 " Don't wrap words by default
set nobackup " Don't keep a backup file
set backupcopy=no " KNOPPIX: Overwrite files/links with w!
set viminfo='20,\"50 " read/write a .viminfo file, don't store more than
" 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time

" Suffixes that get lower priority when doing tab completion for filenames.
" These are files we are not likely to want to edit or read.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc

" We know xterm-debian is a color terminal
if &term; =~ "xterm-debian" || &term; =~ "xterm-xfree86"
set t_Co=16
set t_Sf=^[[3%dm
set t_Sb=^[[4%dm
endif

" Make p in Visual mode replace the selected text with the "" register.
vnoremap p :let current_reg = @"gvdi=current_reg

set enc=big5
imap :wi
imap :wq
imap :q!
map :w
map :wq
map :q!

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
syntax on

" Debian uses compressed helpfiles. We must inform vim that the main
" helpfiles is compressed. Other helpfiles are stated in the tags-file.
set helpfile=$VIMRUNTIME/doc/help.txt.gz

if has("autocmd")
" Enabled file type detection
" Use the default filetype settings. If you also want to load indent files
" to automatically do language-dependent indenting add 'indent' as well.
filetype plugin on

endif " has ("autocmd")

" Some Debian-specific things
augroup filetype
au BufRead reportbug.* set ft=mail
au BufRead reportbug-* set ft=mail
augroup END
" The following are commented out as they cause vim to behave a lot
" different from regular vi. They are highly recommended though.
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make


相關連結:
B2D Linux Server - vimrc

三月 27, 2008
» 【Transmission】scp - 檔案傳輸part1

之前在鳥哥看到一個不錯的指令 scp,主要的功用是用來複製兩主機間的檔案,用法就與 cp 類似,只不過多了個 users @ address

1.將資料由本機上傳到遠端主機jonny@ubuntu:~$ scp FileName jonny@localhost:/home/jonny/
jonny@localhost's password: /* 輸入密碼 */
FileName 100% 0 0.0KB/s 00:00

FileName → 檔案名稱
jonny → 遠端主機上的使用者名稱
localhost:/home/jonny/ → 目的資料夾位址

2. 由遠端主機下載資料
jonny@ubuntu:~$ scp jonny@localhost:~/.bashrc ..bashrc → 在 Linux 的世界裡 . 為隱藏檔

ps: 要使用 scp 之前記得先在本地安裝 ssh-client,遠端則是 ssh-server 喔XD

資料來源:
鳥哥的 Linux 私房菜 - SSH 伺服器 - 4.3 ssh 用戶端連線 - scp

» 【Network】Wireshark - 網路封包分析軟體

寒假時凍仁看那系上的專題生在 Fdora 上那邊打 rpm.. make.. 在那裝了半天都搞不定,索性叫他直接換 Ubuntu Desktop,點幾下就輕輕鬆鬆裝起來啦:P

Wireshark (前身為 Ethereal) - 網路封包分析軟體的功能是擷取網路封包, 並儘可能顯示出最為詳細的網路封包資料。在過去,網路封包分析軟體是非常昂貴,或是專門屬於營利用的軟體。Ethereal的出現改變了這一切。在GNU GPL通用許可證的保障範圍底下,使用者可以以免費的代價取得軟體與其程式碼,並擁有針對其原始碼修改及客製化的權利。Ethereal是目前全世界最廣泛的網路封包分析軟體之一。



安裝方法:
1. 命令達人組

jonny@ubuntu:~$ sudo apt-get install wireshark


2.GUI愛好者
應用程式 → 新增/刪除 → 搜尋 wireshark → 安裝


延伸閱讀:
Wireshark
相關連結:
Wireshark官網

» 【chpasswd】修改 n 筆密碼

新增完 n 筆帳號後,接下來就是要改密碼啦,同樣使用 passwd users 一筆一筆敲是很笨的方法,接下來會使用 chpasswd 來修改大量密碼.. 下命令前真的要想好!不然一次要砍300筆帳號可不是好玩的,手好酸.. Orz

1. 利用 OpenOffice.org Spreadsheet 建立帳號檔(newpwd_list)並存成 .csv,請依以下格式 key in ..

stu001:密碼
stu002:密碼
stu003:密碼
stu004:密碼
stu005:密碼
stu006:密碼

/* 記得數字累加的部分一樣獨立出來.. */

2. 使用 gedit or 文字編輯器 將分隔的符號取代掉

3. 修改密碼
jonny@ubuntu:~$ chpasswd < new_plist


4. 將 /etc/shadow 內的密碼欄資料寫回 /etc/passwd 當中, 並刪除 /etc/shadow 檔案
jonny@ubuntu:~$ sudo pwunconv
jonny@ubuntu:~$ sudo pwconv


延伸閱讀:
【Ubuntu】newusers - 新增 n 筆帳號

資料來源:
OLS3 - RedHat 6.0 大量建帳號的方法
相關連結:
OLS3 - 大量建帳號工具程式 cmpwd 1.0.0 RHS (教育版)

» 【Network】修改固定IP

在 Ubuntu Server 裡沒有 GUI 的介面來設定網路IP,再加上每次重開後使用 ifconfig 更改完的 IP 又會自動被 DHCP 覆蓋過去。這對凍仁這個小網管來說是個很頭痛的問題。

1. 編輯 ip 設定檔

jonny@ubuntu:~$ sudo vi /etc/network/interfaces


2. 更改 eth0 設定,將
auto eth0
iface eth0 inet dhcp

改為
auto eth0
iface eth0 inet static
address 140.127.˙˙˙.˙˙˙
netmask 255.255.255.0
gateway 140.127.˙˙˙.˙˙˙


3. 重新連線並測試有無成功
# 中斷連線
jonny@ubuntu:~$ sudo ifconfig eth0 down

# 啟用網路
jonny@ubuntu:~$ sudo ifconfig eth0 up


/* 建議讓 Server 重開做測試比較好.. */


相關連結:
Ubuntu正體中文wiki - Ubuntu6.10LAMPServer - 11.2設定網路

» 【newusers】新增 n 筆帳號

這幾天一直沒啥空寫 blog,不是 mlms 要鎖IP,就是要在粘老師的學生練習機上面新增300筆帳號,300多筆.. 一筆一筆 key 可是會死人的.. 索性開始自學囉..

開始前先複習一下 /etc/passwdjonny:$1$eb30c0TU$r4ZosogN/Aev83kMS/erq0:1000:1000:Deva-Jonny,,,:/home/jonny:/bin/bash
jonny → 使用者登入名稱(Login name)
$1$eb30c0TU$r4ZosogN/Aev83kMS/erq0 → 加密後的密碼(Password)
1000 → 使用者識別碼(User Identifier)
1000 → 所屬群組識別碼(Group Identifier)
Deva-Jonny,,, → 註解
/home/jonny → 使用者家目錄(Home directory)
/bin/bash → 登入 Shell 名稱

1. 利用 OpenOffice.org Spreadsheet 建立帳號檔(newuser_list)並存成 .csv,需按照以下格式輸入..

stu001::600:600:stu:/home/stu001:/bin/bash
stu002::601:601:stu:/home/stu002:/bin/bash
stu003::602:602:stu:/home/stu003:/bin/bash
stu004::603:603:stu:/home/stu004:/bin/bash

/* 建議使用 1100 以後的 uid,不然會像凍仁一樣發生練習帳號具有 admin, ssh.. 的權限Orz */

/* 在 Spreadsheet 裡遇到需要累加的部分可以獨立出來讓他累加,就像上圖一樣.. */

2. 使用 gedit 將分隔的符號取代掉,分隔符號可能為 ", 空格。開啟 gedit 後按 Ctrl + H 開啟取代視窗,注意!縮排的代號為 \t..

3. 建立帳號
jonny@ubuntu:~$ sudo newusers < newuser_list


4. 將 /etc/shadow 內的密碼欄資料寫回 /etc/passwd 當中, 並刪除 /etc/shadow 檔案
jonny@ubuntu:~$ sudo pwunconv


延伸閱讀:
【Ubuntu】chpasswd - 修改 n 筆密碼

資料來源:
OLS3 - RedHat 6.0 大量建帳號的方法

相關連結:
OLS3 - 大量建帳號工具程式 cmpwd 1.0.0 RHS (教育版)
鳥哥 - pwunconv

» 【Apache】Indexes 目錄列表

在架完 Apache Server 時,預設找不到 link(連結) 時會列出該連結下所有的目錄。有時列出所有的檔案及目錄是不安全的。像凍仁剛架起來的 web 會顯示下圖這樣的訊息.. 這樣不管放啥東西在上面都會被看光光啦XD

1. 刪除 /etc/apache2/sites-available/default 中的 Indexes 來停用目錄列表之功能

1 NameVirtualHost *
2 <VirtualHost *>
3  ServerAdmin webmaster@localhost
4  DocumentRoot /var/www/
5  <Directory />
6    Options FollowSymLinks
7    AllowOverride None
8  </Directory>
9  <Directory /var/www/>
10    Options Indexes FollowSymLinks MultiViews
11    AllowOverride None
12    Order allow,deny
13    allow from all
14    # This directive allows us to have apache2's default start page
15    # in /apache2-default/, but still have / go to the right place
16    #RedirectMatch ^/$ /apache2-default/
17  </Directory>
18
19  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
20  <Directory "/usr/lib/cgi-bin">
21    AllowOverride None
22    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
23    Order allow,deny
24    Allow from all
25  </Directory>
26
27  ErrorLog /var/log/apache2/error.log
28
29  # Possible values include: debug, info, notice, warn, error, crit,
30  # alert, emerg.
31  LogLevel warn
32
33  CustomLog /var/log/apache2/access.log combined
34  ServerSignature On
35
36  Alias /doc/ "/usr/share/doc/"
37  <Directory "/usr/share/doc/">
38    Options Indexes MultiViews FollowSymLinks
39    AllowOverride None
40    Order deny,allow
41    Deny from all
42    Allow from 127.0.0.0/255.0.0.0 ::1/128
43  </Directory>
44
45 </VirtualHost>


2. 重新啟動 apache2
jonny@ubuntu:~$ sudo /etc/init.d/apache2 restart


完成後當 address 錯誤時,會顯示無權限開啟的訊息

相關連結:
紅.攝.情.感. Red maple’s note - Apache 如何關閉目錄列表
鳥哥 - httpd.conf 的基本設定

» 【ssh】DenyUsers, DenyGroups - 阻擋部分使用者連線

凍仁在系學會的 Server 遇到個問題,今天只想提供 apache2, php, mysql 及 ftp 服務給個社團放網頁。想到關閉 ssh 服務一法,這樣就算他們密碼設再爛.. 也只能透過 ftp,這樣在安全性上也更有保障...XD

這邊為鳥哥大人在 詳細設定 sshd 伺服器 中講述的一部分
# 4.6 關於使用者抵擋的設定項目:
DenyUsers *

# 設定受抵擋的使用者名稱,如果是全部的使用者,那就是全部擋吧!
# 若是部分使用者,可以將該帳號填入!例如下列!
DenyUsers test

DenyGroups test
# 與 DenyUsers 相同!僅抵擋幾個群組而已!


凍仁小筆記:
1. 新增 www-no-ssh 群組(用來阻擋使用者之群組)

jonny@ubuntu:~$ sudo groupadd www-no-ssh

2. 將預阻擋的使用者加入此群組
jonny@ubuntu:~$ sudo vi /etc/group
www-no-ssh:x:1015:Orz,QQ,123goTaiwan

3. 在 sshd_conf 裡新增 DenyGroups 來阻擋以上使用者
jonny@ubuntu:~$ sudo vi /etc/ssh/sshd_config
DenyGroups www-no-ssh

4. 重新啟動 ssh
jonny@ubuntu:~$ # sudo /etc/init.d/ssh restart


資料來源:
鳥哥 - 詳細設定 sshd 伺服器

» 【Quota】修改寬限時間(grace time)

當 user 超過 soft 時,寬限時間就會開始倒數。在寬限時間到期之前 user 還可使用剩下的空間直到 hard。不過要是在時間內沒降到 soft 以下,那麼 user 就無法新增檔案及使用剩下的空間。

jonny@ubuntu:~$ edquota -t

接下來進入編輯模式
 GNU nano 2.0.6   檔案: /tmp//EdP.ae5PD58

Grace period before enforcing soft limits for users:
Time units may be: days, hours, minutes, or seconds
 Filesystem  Block grace period Inode grace period
 /dev/sda7     7days      7days


^G 求助 ^O 寫入 ^R 讀檔 ^Y 上頁 ^K 剪下文字 ^C 游標位置
^X 離開 ^J 對齊 ^W 搜尋 ^V 下頁 ^U UnCut Text^T 拼字檢查


延伸閱讀:
【Quota】磁碟配額(Disk Quota)

資料來源:
Novell Suse Linux Enterprise Server 9 管理手冊 - ch7.6

三月 26, 2008

楚楚「凍仁」的 Ubuntu 筆記
jonnyubuntu
凍仁的 Ubuntu 筆記 is about »