shellinabox - 在瀏覽器操作 Linux Shell

 

環境: Fedora 13, Shell In A Box v2.10 (revision 225)

 

安裝 shellinabox

#安裝必要套件
sudo yum install subversion gcc make automake pam-devel openssl-devel openssh-clients

#安裝 Shell In A Box
svn checkout http://shellinabox.googlecode.com/svn/trunk/ shellinabox
cd shellinabox
./configure
make
sudo make install

#若 SELinux 為 Enforcing, 需進行以下處理
sudo cp -Z system_u:object_r:etc_t:s0 etc-pam.d-shellinabox-example /etc/pam.d/

#查看 openssl 版本
rpm -q openssl

#若 openssl 版本高於 0.9.8
#則必須在 openssl 0.9.8 以下的電腦製作 ssl 憑證: certificate.pem
#再把 certificate.pem 檔案複製到 shellinabox 電腦的 /tmp 目錄下

openssl req -x509 -nodes -days 3650 -subj '/CN=localhost/' \
  -newkey rsa:1024 -keyout certificate.pem -out certificate.pem

註: openssl 1.0.0 所產生的 certificate.pem 會造成 ssl handshake failure

執行 shellinabox

#不使用 SSL, 預設聆聽 tcp 4200 port
shellinaboxd --disable-ssl

#使用 SSL, 聆聽 tcp 1234 port
shellinaboxd --cert /tmp --port 1234

#使用 SSL, 聆聽 tcp 1234 port, 黑底白字
shellinaboxd --cert /tmp --port 1234 --css /usr/local/share/doc/shellinabox/white-on-black.css

#使用 SSL, 聆聽 tcp 1234 port, 背景執行
shellinaboxd --background --cert /tmp --port 1234

#在 SELinux=Enforcing 環境下以 root 執行
shellinaboxd --background --cert /tmp --service /:SSH

以 service 方式管理 shellinabox

su -
chmod 700 /usr/local/bin/shellinaboxd
vi /etc/init.d/shellinabox

#!/bin/sh
### BEGIN INIT INFO
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
 
case "$1" in
'start')
    /usr/local/bin/shellinaboxd --background --cert /tmp --service /:SSH
    ;;
'stop')
    pkill shellinaboxd
    ;;
esac
exit 0

chmod +x /etc/init.d/shellinabox
chkconfig --add shellinabox
service shellinabox start

參考資料:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章