| 站 內 搜 尋 |
|
日 曆 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 近 期 文 章 |
| 文 章 分 類 |
在 Internet 上隱匿行蹤!(十四) - 架設 Tor Server(事前準備篇)
要在 Debian 上架設 Tor Server 並非難事。但由於 Tor 的 Debian Package Maintainer 因種種原因建議不要讓 Tor 搭配 Debian Etch 發行,所以現在 Tor 一直都只存在於 Sid 中。而這是很煩人的事,因為沒有幾個 Debian User 會用 Debian Sid 甚至是用 Debian testing 來架設 Server。
如果您不在乎,那麼就讓我們來試著架設 Tor Server 吧!
在 GNU/Linux 裡,若記憶體不敷使用時,常常會借助 Swap 來模擬成記憶體。但如果電腦關機了,Swap 裡的資訊將不會被清除掉,而這將產生極嚴重的安全問題。
解決方案之一是將 Swap 以隨機產生的密鍵加密,等到關機了,這個隨機產生的密鍵也將跟著消失。如此可以確保 Swap 裡的資訊永難被人解讀。
要將 Swap 加密,首先請安裝 cryptsetup 套件:
接下來修改 /etc/crypttab 如下:(其中的 /dev/hda7 為您的 Swap 分割區)
aptitude install cryptsetup
並修改 /etc/fstab 中的 swap 那一行如下:
# <target name> <source device> <key file> <options>
swap /dev/hda7 /dev/urandom swap
接下來重開機。您會注意到開機時會出現類似以下的資訊:
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/mapper/swap none swap sw 0 0
而 /proc/swaps 的內容將會包含以下資訊:
Jan 14 20:59:52 gateway kernel: Adding 1839400k swap on /dev/mapper/swap. Priority:-1 extents:1 across:1839400k
然後執行 dmsetup table 指令,應該會有類似以下的資訊輸出:
# cat /proc/swaps
Filename Type Size Used Priority
/dev/mapper/swap partition 1839400 0 -1
就表示您的 Swap 已成功得加密了。
swap: 0 3678822 crypt aes-cbc-plain b2ac397c804bf82c555b7100567dc171abaab01c3b11d3d31acdac1aad54db8c 0 3:7 0
一般而言,若將記憶體模擬成磁碟並拿來做為 /tmp 的話將會有效加快一些應用程式的執行速度。而相同的,有些暫放在 /tmp 下的資料如果在關機後被人拿去解讀的話也會產生安全上的問題。所以若能將 /tmp 放在記憶體裡,不但能增進系統的速度,在關機後 /tmp 裡的資料也將跟著消失,這將是一舉兩得的做法。
在 Debian GNU/Linux 裡,預設上就會把記憶體拿來模擬成磁碟了,也就是您在 df 指令裡所看到的 /dev/shm。由於系統記憶體十分寶貴,所以 /dev/shm 會動態調整其大小,但您還是可以修改 /etc/default/tmpfs 來指定其限額,例:
然後請再修改 /etc/fstab 讓 /tmp 在開機時能掛在 /dev/shm 上,例:
# SHM_SIZE sets the maximum size (in bytes) that the /dev/shm tmpfs can use.
# If this is not set then the size defaults to the value of TMPFS_SIZE
# if that is set; otherwise to the kernel's default.
#
# The size will be rounded down to a multiple of the page size, 4096 bytes.
SHM_SIZE=200m
設定完成後,重新開機您就會發現 /tmp 己經掛在 tmpfs 上了:
# <file system> <mount point> <type> <options> <dump> <pass>
tmpfs /tmp tmpfs size=100m,mode=1777 0 0
~# df
檔案系統 1K-區段 已用 可用 已用% 掛載點
tmpfs 102400 0 102400 0% /tmp
建議您能安裝 ntpdate 套件來讓您的機器在開機時會自動對時。您也可以在任何時候以 root 身份使用以下指令來進行對時:
ntpdate stdtime.sinica.edu.tw
為了讓您的 Tor Sever 能替使用者進行 DNS 解析,請確認這台機器本身的 DNS 設定無誤。一般而言,使用 Hinet 的 DNS Server 是個不錯的主意。請修改 /etc/resolv.conf 如下:
然後用 host 指令來確認您的機器是否能正確進行 DNS 解析。例:
nameserver 168.95.192.1
而 host 指令包含於 bind9-host 套件之中。請用 apt-get/aptitude 指令安裝即可。
# host www.google.com.tw
www.google.com.tw is an alias for www.google.com.
www.google.com is an alias for www.l.google.com.
www.l.google.com has address 66.249.89.104
www.l.google.com has address 66.249.89.99
www.google.com.tw is an alias for www.google.com.
www.google.com is an alias for www.l.google.com.
www.google.com.tw is an alias for www.google.com.
www.google.com is an alias for www.l.google.com.
如果您擔心使用 Tor Server 會發生什麼安全上的問題,建議您能使用 chroot、VServer 或 Xen 等虛擬主機來執行 Tor Server。
而使用 chroot 來架設 Tor 的詳細步驟請參考:
(待續)
Re: 在 Internet 上隱匿行蹤!(十四) - 架設 Tor Server(事前準備篇)
http://wiki.noreply.org/noreply/TheOnionRouter/TorOnDebian
這有提供 stable 的 Debian tor package
[回應] guest @ 24/01/2007, 02:02