2014年12月16日 星期二

Sikuli IDE install in OS X Yosemite


  1. Install JAVA SDK 1.7
  2. Download Sikuli version 1.1.0
  3. Create new folder and move "sikulixsetup-1.1.0.jar" to folder.
  4. Double click "sikulixsetup-1.1.0.jar" to install Sikuli.
  5. In folder have file "sikulix.jar", double click it, you cat see Sikuli IDE.

2014年11月20日 星期四

How to change Tomcat 7 JDK/JVM

1. Usually Tomcat 7 default use Java SDK 1.6
2. First download Oracle Java SDK 1.7 or 1.8
3. vim /etc/default/tomcat7
4. Change JAVA_HOME path and restart Tomcat 7
5. Finish

2014年9月24日 星期三

How to used iptable block port by Mac Address

iptables -A INPUT -i eth0 -p udp --dport 5060 -j ACCEPT


iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT


iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT


iptables -A INPUT -i eth0 -p tcp --dport 443 -j ACCEPT


iptables -A INPUT -i eth0 -p tcp --dport 1883 -j ACCEPT


iptables -A INPUT -p tcp --destination-port 7777 -m mac --mac-source 28:D2:44:2A:EF:AD -j ACCEPT


iptables -A INPUT -i eth0 -m state --state NEW,INVALID -j DROP

----------------------------------------------------------

Allow UDP 5060, TCP 22,80,443,7777(By Mac Address)

Red Command is deny all connection, only Allow port can access.

2014年9月5日 星期五

How to setting Asterisk to Amazon

Hello,

I would like you to check and configure the following to allow Asterisk work correctly:

1. Edit your "sip.conf" and add the following settings.

    $ vim  /etc/asterisk/sip.conf

      #add the two lines in your sip.conf
       [general]
       localnet=172.31.0.0/255.255.0.0
       externip=54.254.242.156
     
       [provider]
       nat=yes

2.  Reload asterisk.

     $ asterisk -rvvvvvvv

Looking forward to your feedback to assist in further troubleshooting.

Best regards,

Billy O.
Amazon Web Services
We value your feedback. Please, rate my response using the link below.

2014年8月31日 星期日

Database maps to Sqlalchemy

  1. use pip install "sqlacodegen".
  2. command $sqlacodegen mysql://users:pass@localhost/db_name --outfile tables.py.
  3. Finish.

2014年8月1日 星期五

uWSGI and Nginx

  1. uwsgi --socket /tmp/uwsgi.sock -w Flask:app --chmod-socket=666
  2. /etc/nginx/site-enable/
  3. # mysite_nginx.conf

    # the upstream component nginx needs to connect to
    upstream flask {
        server unix:///tmp/uwsgi.sock;
    }

    # configuration of the server
    server {
        # the port your site will be served on
        listen      7777;
        # the domain name it will serve for
        server_name PinLiang.example.com; # substitute your machine's IP address or FQDN
        charset     utf-8;

        # max upload size
        client_max_body_size 75M;   # adjust to taste

        # Django media
        location /media  {
            alias /home/pinliang/Restful/Money/media;  # your Django project's media files - amend as required
        }

        location /static {
            alias /home/pinliang/Restful/Money/static; # your Django project's static files - amend as required
        }

        # Finally, send all non-media requests to the Django server.
        location / {
            uwsgi_pass  flask;
            include     /home/pinliang/Restful/Money/uwsgi_params; # the uwsgi_params file you installed
        }
    }
  4. [uwsgi]
    chdir = /home/pinliang
    module = Flask
    callable = app
    master = true
    processes = 1
    socket = /tmp/uwsgi.sock
    chmod-socket = 666
    vacuum = true

2014年6月4日 星期三

How to used ssh and sftp command?

If your want remote server use default Port, then you just use command:

$ ssh yourremotename@ipaddress
$ sftp yourremotename@ipaddress

If remote server have setting special port then use command:

$ ssh yourremotename@ipaddress -p yourportnumber
$ sftp -oPort=yourportnumber yourremotename@ipaddress

2014年5月26日 星期一

How to update/install openssl version 1.0.1g on Ubuntu 14.04 (Solve Openssl Heartbleed problem)

  1. Check your openssl version used command $ sudo openssl version
  2. If your version not 1.0.1g or 0.9.8, suggest to update openssl to 1.0.1g.
  3. Remove original openssl $ sudo apt-get purge openssl
  4. $ sudo apt-get autoremove && apt-get autoclean
  5. Download 1.0.1g source
  6. $ ./config --prefix=/usr/
  7. $ make
  8. $ make install_sw
  9. Used command $ sudo openssl version check your openssl version.

Reference:
  1.  make: *** [install_docs] Error 255
  2.  Documentation fixes for openssl-1.0.1g(Ubuntu 14.04)
  3.  Upgrade OpenSSL on Ubuntu 14.04

2014年5月14日 星期三

How to install Skype in Ubuntu 14.04

  1. I used operation system is 32Bit, Xfce.
  2. Download source code from Skype.
  3. $ apt-get install gdebi-core
  4. $ gdebi skype-ubuntu-precise_4.2.0.13-1_i386.deb

2014年5月5日 星期一

How to install Libreoffice used source code

  1. First Download Source Code.
  2. Decompress file.
  3. Go to path $ cd {your file path}/RPMS/ or $ cd {your file path}/DEBS/
  4. Install $ yum localinstall *.rpm (CentOS, Fedora) or $ dpkg -i *.deb (Ubuntu, Debian)
  5. Finish. 
P.S. Red words is command.

2014年5月2日 星期五

How to change Linux default Java compiler

  1. Linux Java default is OpenJDK, I want to change Oracle Java SDK.
  2. Download Oracle Java SDK
  3. $ /usr/sbin/update-alternatives --install /usr/bin/java java "your download path"/bin/java 99
  4. $ /usr/sbin/update-alternatives --config java
  5. Choice your Oracle Java SDK.
  6. Finish. 
P.S. Red words is command

Gcin 安裝嘸蝦米

1. 首先先上Google搜尋 nosseing,下載相關檔案.
2. 解壓縮後將nosseing.gtab覆製到 /usr/share/gcin/table/
3. 重新開機即可使用無蝦米.

2014年5月1日 星期四

OpenSUSE 13.1 64Bit Install flash player

User just need click this connection. then system will auto-install.

http://software.opensuse.org/package/flash-player

Nyamuk 用法

在 test case 裡面有兩個檔案, pubnya.py, subnya.py

Publish由abc送訊息Hello給ActiveMQ.Advisory.Connection.pin這個Topic: python pubnya.py localhost abc ActiveMQ.Advisory.Connection.pin Hello
Subscript為監聽:python subnya.py localhost test ActiveMQ.Advisory.Connection.pin

2014年4月28日 星期一

Google Compute Engine on Windows tutorial

1. First you need to install Cygwin 32 Bit version.
2. Running install Cygwin you need to install curl, wget, python library.
3. Use Cygwin run command "curl https://dl.google.com/dl/cloudsdk/release/install_google_cloud_sdk.bash | bash" to get fild.
4. Use Cygwin under google-cloud-sdk folder run command  "./install.sh".
5. Certification your account "gcloud auth login"
6. Open browser to Google Developers Console there have connection command.

~Finish~

2014年1月28日 星期二

fail2ban for asterisk tutorial

1. 安裝fail2ban
2. /etc/asterisk/logger.conf 設定

   [general]
   dateformat=%F %T

3. /etc/fail2ban/jail.conf 新增

   [asterisk-iptables]
   # if more than 4 attempts are made within 6 hours, ban for 24 hours
   enabled  = true
   filter   = asterisk
   ignoreip = 168.192.0.1
   action   = iptables-allports[name=ASTERISK, protocol=all]
              sendmail[name=ASTERISK, dest=you@yourmail.co.uk, sender=fail2ban@local.local]
   logpath  = /var/log/asterisk/messages*
   maxretry = 4
   findtime = 21600
   bantime = 86400

4. /etc/fail2ban/filter.d/asterisk.conf 新增下表(給Asterisk 1.8 and Asterisk 11使用)

# Fail2Ban configuration file
#
#
# $Revision: 251 $
#

[INCLUDES]

# Read common prefixes. If any customizations available -- read them from
# common.local
before = common.conf


[Definition]

#_daemon = asterisk

# Option:  failregex
# Notes.:  regex to match the password failures messages in the logfile. The
#          host must be matched by a group named "host". The tag "<HOST>" can
#          be used for standard IP/hostname matching and is only an alias for
#          (?:::f{4,6}:)?(?P<host>\S+)
# Values:  TEXT
#
# Asterisk 1.8 uses Host:Port format which is reflected here

failregex = NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - Wrong password
           NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - No matching peer found
           NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - No matching peer found
           NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - Username/auth name mismatch
           NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - Device does not match ACL
           NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - Peer is not supposed to register
           NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - ACL error (permit/deny)
           NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - Device does not match ACL
           NOTICE.* .*: Registration from '\".*\".*' failed for '<HOST>:.*' - No matching peer found
           NOTICE.* .*: Registration from '\".*\".*' failed for '<HOST>:.*' - Wrong password
           NOTICE.* <HOST> failed to authenticate as '.*'$
           NOTICE.* .*: No registration for peer '.*' \(from <HOST>\)
           NOTICE.* .*: Host <HOST> failed MD5 authentication for '.*' (.*)
           NOTICE.* .*: Failed to authenticate user .*@<HOST>.*
           NOTICE.* .*: <HOST> failed to authenticate as '.*'
           NOTICE.* .*: <HOST> tried  to authenticate with nonexistent user '.*'
           VERBOSE.*SIP/<HOST>-.*Received incoming SIP connection from unknown peer
 
# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
#
ignoreregex =

5. service ufw restart (重啟iptables)
6. service fail2ban restart (重啟fail2ban)

註:ufw 為Ubuntu下重啟iptables指令, 其它版本Linux 應該都是用iptables

驗證
1. iptables -L -n (即可看到被iptables drop掉的IP)
2. fail2ban-client status asterisk-iptables (即可看到fail2ban監控狀態)
3. iptables -D fail2ban-ASTERISK -s 42.78.174.92 -j DROP (不小心4次驗證失敗IP被加到iptables, 將IP從iptables解放出來)

參考文件
1. http://www.fail2ban.org/wiki/index.php/Asterisk
2. http://tc.itkee.com/os/detail-28ad.html
3. http://askubuntu.com/questions/161551/how-to-start-stop-iptables-in-ubuntu-12-04
4. http://pulipuli.blogspot.tw/2011/07/centosfail2ban.html#postcata1389669540911_anchor17