TIPs

วันนี้มีเคล็ดลับสำหรับท่านที่ใช้ ubuntu linux และต้องการ remote เข้าไปที่
อุปกรณ์ต่างๆเช่น router เพื่อทำการ config ค่าต่างที่ต้องการ

ในตัวอย่างนี้ผมมี usb port แปลงเป็น serial port 1 ตัว
ซึ่งพอเสียบ usb แล้ว มันจะ detect เจอเป็น /dev/ttyUSB0 โดย default
และต้องเช็ค log ก่อนว่า linux มันกำหนดให้เป็น device อะไร

$tail -f /var/log/messegs

May 5 09:07:53 ubuntu kernel: [46728.348000] usb 4-1: new full speed USB device using uhci_hcd and address 2
May 5 09:07:53 ubuntu kernel: [46728.500000] usb 4-1: configuration #1 chosen from 1 choice
May 5 09:07:53 ubuntu kernel: [46728.612000] usbcore: registered new interface driver usbserial
May 5 09:07:53 ubuntu kernel: [46728.612000] drivers/usb/serial/usb-serial.c: USB Serial support registered for generic
May 5 09:07:53 ubuntu kernel: [46728.616000] usbcore: registered new interface driver usbserial_generic
May 5 09:07:53 ubuntu kernel: [46728.616000] drivers/usb/serial/usb-serial.c: USB Serial Driver core
May 5 09:07:53 ubuntu kernel: [46728.684000] drivers/usb/serial/usb-serial.c: USB Serial support registered for pl2303
May 5 09:07:53 ubuntu kernel: [46728.684000] pl2303 4-1:1.0: pl2303 converter detected
May 5 09:07:53 ubuntu kernel: [46728.688000] usb 4-1: pl2303 converter now attached to ttyUSB0
May 5 09:07:53 ubuntu kernel: [46728.688000] usbcore: registered new interface driver pl2303
May 5 09:07:53 ubuntu kernel: [46728.688000] drivers/usb/serial/pl2303.c: Prolific PL2303 USB to serial adaptor driver

จากตัวอย่างนี้ linux กำหนดให้เป็น ttyUSB0
จากนั้น เรียกโปรแกรม minicom ขึ้นมา config ค่าก่อนใช้งาน

$minicom -s

ให้เลือกไปที่ Serial port setup ก่อน
เลือก A แล้วกำหนด device เป็น /dev/ttyUSB0
เลือก E แล้วกำหนดเป็น 9600 8N1
เลือก F hardware flow control เลือกเป็น No
แล้วออกไปที่ menu หลัก

จากนั้นให้เลือก Save setup as dfl และ Exit from minicom ตามลำดับ
เป้นอัน เสร็จสิ้นขั้นตอนการ config minicom

ให้ทำการทดสอบดูว่า สามารถ connect ไปยังอุปกรณ์ router ได้หรือเปล่า


$minicom


หมายเหตุ
บน Ubuntu user สามารถใช้ได้งานเลย
บน RHEL ต้องใช้งานด้วย root account และก่อนใช้งานต้อง export TERMINAL environment ก่อนทุกครั้ง
#export TERM=vt100

ใน rhel4 เราจะมีคำสั่ง ext2online สำหรับใช้ resize ขนาดของ harddisk
แต่พอมาเป็น FC6 , RHEL5 คำสั่ง ext2online หายไป
และให้ใช้คำสั่งนี้แทน

#resize2fs /dev/rootvg/lv04

ความหมายจะเหมือนคำสั่ง ext2online ครับ คือ ขยายพื้นที่ได้ โดยที่ยังใช้งานระบบอยุ่
และไม่ต้องทำการ unmount

ข้อมูลเพิ่มเติม
man resize2fs
www.redhat.com
www.google.com


การใช้ linux หลายๆเครื่อง แล้วแต่ละเครื่องมี user+passwd ไม่เหมือนกัน
บางทีก้อรู้สึกไม่อยากพิมพ์ password หลายๆครั้ง เลยมีจะบอกวิธี สำหรับคนขี้เกียจแบบผม

system profile
- first box: 192.168.1.2 srv01
- second box: 192.168.1.3 srv02

เริ่มเลย
1. ให้ทำการ generate ssh key ก่อน โดยเคาะ enter อย่างเดียวไม่ต้องกำหนด pass-phase
srv01#ssh-keygen -t dsa
srv02#ssh-keygen -t dsa

2. ให้ทำการคัดลอก id_dsa.pub เปลี่ยนเป็นไฟล์ authorized_keys2 และคัดลอกไปยังเครื่องที่สองด้วย
srv01#cd ~/.ssh
srv01#cat id_dsa.pub > authorized_keys2
srv01#scp authorized_keys2 root@srv02:~/.ssh
srv02#cat id_dsa.pub >> authorized_keys2
srv02#scp authorized_key2 root@srv01:~/.ssh


3. ทำการทดสอบการใช้งาน ด้วยคำสั่งตามข้างล่าง
srv01#ssh srv02 hostname
srv02#ssh srv01 hostname
srv01#ssh srv02
srv02#ssh srv01

จบเท่านี้ แค่นี้ก้อใช้งานได้แล้ว

ข้อมูลเพิ่มเติม
man ssh
www.google.com