2015年2月12日 星期四

Ubuntu 掃木馬程式 chkrootkit + rkhunter

一、下載
sudo apt-get install chkrootkit
sudo apt-get install rkhunter

二、更新與掃描
sudo chkrootkit
sudo rkhunter –check
sudo rkhunter --update


參考鏈結:http://www.arthurtoday.com/2012/01/ubuntu-rootkit-scanner.html

Logcheck on ubuntu14.10

一、Logcheck 安裝
sudo apt-get install logcheck
設定要把log寄到你的信箱
sudo vim /etc/logcheck/logcheck.conf
內容修改:
...
SENDMAILTO="xxxxxx@gmail.com"
...
測試是否可以把log寄到信箱
sudo -u logcheck logcheck

二、msmtp 安裝
sudo apt-get install msmtp
將msmtp 寄件者改成gmail,內容如下:
sudo vim /etc/msmtprc
account gmail
account default: gmail
host smtp.gmail.com
from xxxxxx@gmail.com
protocol smtp
tls on
auth on
port 587
user xxxxxx@gmail.com
password xxooxx
logfile /var/log/msmtp.log
tls_starttls on
tls_certcheck off
測試msmtp寄mail
echo "Test from msmtp" | msmtp xxxxxx@gmail.com
將logcheck寄信功能改成msmtp來寄
sudo ln -s /usr/bin/msmtp /usr/local/sbin/sendmail
sudo ln -s /usr/bin/msmtp /usr/local/bin/sendmail
測試是否可以寄信
echo -e "Subject: I hope I receive this\nTest from sendmail" | sendmail xxxxxx@gmail.com


參考鍵結:http://nixnote.blogspot.tw/2013/10/configuring-logcheck-on-ubuntu.html

Apache2.4 + multi Tomcat8 + mod_jk(binary) on ubuntu14.10

Apache2.4安裝教學Tomcat8安裝教學

軟體準備

一、下載及安裝
sudo wget http://apache.stu.edu.tw/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.40-src.tar.gz
sudo tar xvzf tomcat-connectors-1.2.40-src.tar.gz
cd tomcat-connectors-1.2.40-src/native
sudo ./buildconf.sh
sudo ./configure --with-apxs=/usr/local/apache2/bin/apxs
sudo make
sudo make install
查看 /usr/local/apache2/modules/ 是否有mod_jk.so
ls -al /usr/local/apache2/modules/

二、mod_jk與Apache2設定
sudo vim /usr/local/apache2/conf/workers.properties
內容新增如下:
worker.list=DLOG4J,DLOG4J1, status
worker.DLOG4J.type=lb
worker.DLOG4J.sticky_session=1
worker.DLOG4J.error_escalation_time=0
worker.DLOG4J.max_reply_timeouts=10
worker.DLOG4J1.type=lb
worker.DLOG4J1.sticky_session=1
worker.DLOG4J1.error_escalation_time=0
worker.DLOG4J1.max_reply_timeouts=10

worker.s1.reference=worker.template
worker.s1.port=8009
worker.s1.host=localhost
worker.s1.lbfactor=5
worker.s2.reference=worker.template
worker.s2.port=8010
worker.s2.host=localhost
worker.s2.lbfactor=5

worker.template.type=ajp13                    
worker.template.socket_connect_timeout=5000
worker.template.socket_keepalive=true
worker.template.ping_mode=A
worker.template.ping_timeout=10000
worker.template.connection_pool_minsize=0
worker.template.connection_pool_timeout=600
worker.template.reply_timeout=300000
worker.template.recovery_options=3

worker.retries=3
worker.DLOG4J.balanced_workers= s1
worker.DLOG4J1.balanced_workers= s2

worker.status.type=status
worker.s1.port=8009 這一個port請看你tomcat/conf/server.xml的AJP port
sudo vim /usr/local/apache2/conf/httpd.conf
內容新增如下:
...
#LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
#LoadModule rewrite_module modules/mod_rewrite.so

#這邊新增
LoadModule jk_module modules/mod_jk.so

JkWorkersFile conf/workers.properties
JkLogFile     /var/log/mod_jk.log
JkLogLevel    info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /private/admin/status status
JkMount /test/* DLOG4J
JkMount /test1/* DLOG4J1
請在tomcat webapps裡面新增test資料夾,在寫一支index.jsp,看是否用80 port可不可以進來。

參考鏈結: http://www.altj.com/setup-mod_jk-on-ubuntu-dapper-for-ofbiz/

How to install multi Tomcat8 binary on ubuntu14.10(64Bit)

軟體準備
前提:事先把JDK環境安裝完成。

一、下載及設定路徑
sudo cd /usr/local/tomcat
sudo wget http://apache.stu.edu.tw/tomcat/tomcat-8/v8.0.18/bin/apache-tomcat-8.0.18.tar.gz
sudo tar xzvf apache-tomcat-8.0.18.tar.gz
sudo cp ./apache-tomcat-8.0.18 /usr/local/tomcat/apache-tomcat-8.0.18-1
sudo cp ./apache-tomcat-8.0.18 /usr/local/tomcat/apache-tomcat-8.0.18-2

二、新增Tomcat的使用者
sudo useradd -s /sbin/nologin -d /opt/tomcat/temp tomcat
 cd /usr/local/tomcat

三、啟動/停止Tomcat

啟動
cd /usr/local/tomcat/apache-tomcat-8.0.18-1/bin
sudo ./startup.sh
sudo ./catalina.sh run
sudo ./catalina.sh start
停止
sudo ./shutdown.sh
sudo ./catalina.sh stop

四、安裝Tomcat服務
sudo vim /etc/init.d/tomcat8-1
內容新增如下:
#!/bin/bash
export CATALINA_HOME=/usr/local/tomcat/apache-tomcat-8.0.18-1
PATH=/sbin:/bin:/usr/sbin:/usr/bin
start() {
 sh $CATALINA_HOME/bin/startup.sh
}
stop() {
 sh $CATALINA_HOME/bin/shutdown.sh
}
case $1 in
  start|stop) $1;;
  restart) stop; start;;
  *) echo "Run as $0 "; exit 1;;
esac
儲存後,離開。
sudo chmod 755 /etc/init.d/tomcat8-1
sudo service tomcat8-1 start
sudo /etc/init.d/tomcat8-1 start
sudo service tomcat8-1 stop
sudo /etc/init.d/tomcat8-1 stop
sudo update-rc.d tomcat8-1 defaults
一個Tomcat的服務就安裝完成。

五、多個Tomcat設定
sudo vim /usr/local/tomcat/apache-tomcat-8.0.18-2/conf/server.xml
內容如下:
...
<Server port="8005" shutdown="SHUTDOWN">
...
...
<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
...
...
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
...
...
將 8005、8080、8009的port改沒有使用過的port,在從剛剛的第三個步驟開始設定。


參考鏈結:http://www.ntu.edu.sg/home/ehchua/programming/howto/Ubuntu_HowTo.html#tomcat