Monday, March 12, 2007

Yum Yum

ก่อนที่จะใช้ yum ได้จะต้อง import GPG ก่อน
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
สำหรับ CentOS4 ใช้
rpm --import /usr/share/rhn/RPM-GPG-KEY-centos4

เสร็จแล้วก่อนอื่นสั่ง
yum update -y ก่อนเลย

วิธีการเพิ่ม Repository ให้กับ yum

import gpg key เพื่อตรวจสอบว่าข้อมูลของ package ไม่ได้ถูกแก้ไข
wget http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
rpm --import RPM-GPG-KEY.dag.txt

cd /etc/yum.repos.d
สร้างไฟล์ชื่อ dag.repo แล้วเพิ่มข้อมูลดังนี้เข้าไป

[dag]
name=Dag RPM Repository for CentOS
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1

ลองสั่ง yum install pine lynx -y ดู

ถ้าต้องการเอา package ออกให้สั่ง yum remove pine
ถ้าต้องการค้นหา package สั่ง yum search perl*
yum list available
yum list installed <- ดูว่า install อะไรอยู่บ้าง หรือ rpm -q
yum clean all <- clear disk space yum info lynx สั่ง schedule update โดยให้ yum ตอนกลางคืน
chkconfig yum on <- สั่งให้ yum ทำงานที่ run level ไหนบ้าง แต่ยังไม่ได้สั่งให้ทำงานจริงๆ service yum start <- สั่งให้ yum ทำงานNote
ส่วนใหญ่แล้ว Package ของ 3rd party จะใหม่กว่าของ Official แต่เราต้องการความ stable ของ Package จาก official จึงไม่แนะนำให้ update ทับ package ของ Official วิธีการทำแบบนี้ได้ต้องอาศัย pluginyum install yum-plugin-protectbaseแก้ไขไฟล์ /etc/yum.conf เพิ่มบันทัด plugins=1 เข้าไปแก้ไขทุกๆไฟล์ .repo ที่อยู่ใน /etc/yum.repos.d โดยเพิ่ม
protect=1 ให้กับ Official Repository
protect=0 ให้กับ 3rd party Repositaryเพราะว่า protect=0 จะไม่สามารถ update protect=1 ได้ถึงแม้ว่ามันจะใหม่กว่าก็ตามถ้าใน .repo มีการใส่ repository อยู่หลายแห่ง น่าจะต้องใส่เพิ่ม protect=0 ให้กับทุกๆที่Yum 3rd part: List of other repositorieshttp://www.ducea.com/2006/10/22/yum-3rd-part-list-of-other-repositories/

Tuesday, March 06, 2007

OpenVZ VS Xen, Vmware

The operating system level architecture(OpenVZ) has low overhead that helps to maximize efficient use of server resources. Due to a single-kernel approach, this type of virtualization introduces only a negligible overhead and allows running hundreds of virtual private servers on a single physical server. In contrast, approaches such as emulation (like VMware) and paravirtualization (like Xen or UML) cannot achieve such level of density, due to overhead of running multiple kernels. On the other hand, operating system-level virtualization does not allow running different operating systems (i.e. different kernels), although different libraries, distributions etc. are possible

Since there is a single OS kernel which maintains all the partitions, isolation and resource management become very important. Without proper isolation security can be compromised, and without proper resource management an application from one partition can abuse resources and thus cause a denial of service for other partitions. Resources controlled and limited can include: CPU time, disk space, I/O bandwidth, network access, and all the other finite resources like RAM, shared memory, locked pages, number of processes, socket buffers etc. For example, OpenVZ provide a set of more than 20 finite resources that are accounted and limited on a per-partition basis.
Compared to the hardware-assisted virtualization solutions (like IBM's LPAR), OS-level virtualization has the benefit of running on inexpensive commodity hardware

OS level virtualization solutions initially gained popularly with service providers who needed a very low overhead, customizable, cost effective solution to provide hosting services to customers. The technology is now becoming more widely deployed as many different industries and customers are recognizing the benefits and differences between OS virtualization and hardware virtualization. The common uses and scenarios now include server and OS consolidation, business continuity (disaster recovery and high availability) and centralized desktop virtualization.

An owner (root) of OpenVZ physical server (also known as Hardware Node) can see all the VE processes and files. That makes mass management scenarios possible. Consider that VMware or Xen is used for server consolidation: in order to apply a security update to your 10 virtual servers you have to log in into each one and run an update procedure – the same you would do with the ten real physical servers.
In OpenVZ case, you can run a simple shell script which will update all (or just some selected) VEs at once.

http://wiki.openvz.org/Introduction_to_virtualization

http://en.wikipedia.org/wiki/Operating_system-level_virtualization

Saturday, January 27, 2007

Removing Old Network Card

Create environmental variable:
DEVMGR_SHOW_NONPRESENT_DEVICES=1
Reboot, then go into device manager and VIEW\SHOW HIDDEN DEVICES.
You will then see all of the hardware ghosts. Right click and uninstall under network adapters.

Sunday, December 24, 2006

วิธีแก้ปัญหาของ Arcserve Backup กับ IE7

Problem:
BAB GUI does not work correctly after installing Internet Explorer 7.

Error "failed to create or open document" is received when:
1. Accessing the BAB GUI using Remote Desktop Connection or Terminal services.
2. Accessing the BAB GUI from a machine that has IE 7.0 and Novell Client installed on it.

Solution:
1. Shut down BAB GUI.
2. Rename psapi.dll located in c:\Program Files\CA\BrightStor ARCserve Backup to psapi.dll.org.
3. Start up BAB GUI.

Friday, December 15, 2006

ISA Publish PcAnywhere Host


1. ที่ Router ทำ Port Forward ให้ไปที่ external interface ของ ISA
2. สร้าง New Protocal ขึ้นมาเช่นให้ชื่อว่า PcEveryWhere แล้วกำหนด port ให้กับ protocal ดังนี้


Thursday, December 07, 2006

Tomato Firmware

http://www.polarcloud.com/tomato
เป็น firmware ที่เสถียรดีมาก
สามารถสั่ง schedule reboot ได้จาก cron โดยใช้คำสั่ง ในหน้า Web Config/Administration/Scripts/Init
# cru a boot "0 0 * * * /sbin/reboot"
จะ reboot ตอนเที่ยงคืนของทุกๆวัน

Cron Utility
add: cru a <"min hour day month week command">
delete: cru d
list: cru l

Wednesday, November 29, 2006

Disable Remote Desktop/ Remote Assistance by GPO

Remote Desktop
Computer Configuration/ Administrative Templates/ Windows Components/ Terminal Services
Allow users to connect remotely using Terminal Services = Disable
Do not allow local administrators to customize permissions = Enable

Remote Assistance
Computer Configuration/ Administrative Templates/ System/Remote Assistance
Solicited Remote Assistance = Disable
Offer Remote Assistance = Disable

Tuesday, November 21, 2006

วิธีเปลี่ยน Port ของ Remote Desktop/ Terminal Server

ไปที่ HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp

ที่ subkey PortNumber ให้เปลี่ยนเป็น port ที่ต้องการ เช่น 3388 (default คือ port 3389)
เสร็จแล้ว reboot ก่อน 1 ครั้ง

การ connect จากเครื่อง Client ให้ใส่ port number หลังจากชื่อหรือ ip server เช่น

192.168.0.1:4000 หรือ myserver.com:8000

Configure RDP over SSL with SelfSSL

Windows Time Services

เครื่องทุกเครื่องที่อยู่ใน Domain จะ Sync time มาจาก PDC Master แล้ว PDC Master ก็จะ Sync time มาจาก Time Server ภายนอกอีกทีปกติแล้วจะเป็น time.windows.com เราวิธีตรวจสอบว่า Sync time มาจากไหนได้จากคำสั่ง
net time /querysntp

For Windows XP
ถ้าต้องการเปลี่ยน time server ใช้คำสั่ง
net time /setsntp:pool.ntp.org
เสร็จแล้วสั่ง restart windows time service จากคำสั่ง
net stop w32time
net start w32time

For Windows Server 2003

net time /setsntp:pool.ntp.org
w32tm /config /update
w32tm /resync /rediscover /nowait

ถ้ายังไม่ได้ผลให้ลงโปรแกรม SP TimeSync ที่เครื่อง Domain Controller ที่เป็น PDC Master (หา PDC Master ได้จาก Active Directory User and Computer ตรง Operation Master) เลือก Version ที่เป็น Unicode สำหรับ Windows Server 2003

Terminal Server Performance Tweaks

The first thing to do is to override some desktop settings to reduce the amount of screen refreshes, which lowers bandwidth used, which makes the TS respond "faster". First we will remove Windows Resize Animation, when a user minimizes or maximizes a window it will be immediate, and not shrink slowly on its way down to the task bar. Open up the registry with regedit and browse to:

HKLMSYSTEMCurrentControlSetControlTerminalServerWinStationsRDP-TcpUserOverrideControl PanelDesktop

And change these values:

"AutoEndTasks" REG_SZ "1" (terminates programs that aren’t responding)
"CursorBlinkRate" REG_SZ "-1" (prevents the cursor from blinking, cutting down on screen redraws)
"DragFullWindows" REG_SZ "0" (disables "show contents" while dragging a window)
"MenuShowDelay" REG_SZ "10" (delay for showing submenus)
"WaitToKillAppTimeout" REG_SZ "20000" (number of milliseconds to wait before terminating an application that has stopped responding)
"SmoothScroll Dword" REG_DWORD "00000000" (disables smooth scrolling)
"Wallpaper" REG_SZ "(none)" (disables wallpaper)

Now browse over to:

HKLMSYSTEMCurrentControlSetControlTerminalServerWinStationsRDP-TcpUserOverrideControl PanelDesktopWindowMetrics

And change this value:

"MinAnimate" REG_SZ "0" (disables the animation when resizing a window)

If any of these keys, subkeys or values do not exist, create them. This will not really improve server performance but it will enhance the user experience and make it appear to be faster to end users, which hopefully cuts down on complaints. For your convenience I have written a REG file which you can get here. Save as tsperf.reg and run it on the terminal server.

Terminal Services Command Line Administration

Managing your Windows 2003 Terminal Server can be done faster and easier with a few simple command line tools. There are a lot of them so hang on!

Failure Codes ของ Event ID 675 และ 680 ใน Security log

Audit Account Logon - Means people connecting across the network
Audit Logon Events - Means a keyboard logon, someone at the very Domain Controller

675 Pre-authentication failed. This event is generated on a Key Distribution Center (KDC) when a user types in an incorrect password.
680 Successful or Failed logon attempt.

ถ้าต้องการจะดู Failure Codes ของ Event 675 กับ 680 จะต้องเลือกทั้ง Success และ Failuer Event

Event ID 680 จะใช้ log เหตุการณ์ success หรือ failure logon ซึ่งจะมี NT Status Code อยู่ 6 code ที่บอกรายละเอียดของ Event ID 680 นี้ เราสามารถใช้ในการตรวจสอบและแก้ปัญหาที่เกิดขึ้นได้

0xC000006A - This code means that a user has tries to log on and entered the password incorrectly.

0xC000006F - This code means that the user was prevented from logging on due to a logon time restriction.

0xC0000064 - This code appears when someone tries to logon with a non-existant account.

0xC0000070 - This code appears when a user attempts to logon to a computer that they are not allowed to logon to.

0xC0000071 - This code appears when the users password has expired.

0xC0000072 - This code appears when a user has entered the wrong password too many times and the account has been disabled.

สำหรับ Event ID 675
0x6 The username does not exist
0x17 The account has expired
0x18 Username exists, but password is wrong
0x25 Workstation's clock is out of synch

Share and NTFS permission

ตั้งแต่ Windows XP SP1 กับ Windows 2003 เป็นต้นมา จะกำหนด default share permission ให้เป็น Read Only จากเดิมที่เป็น Full Controll สำหรับ Everyone Group แต่อย่างไรก็ตามเราควรที่จะเอา Everyone ออกแล้วใส่เป็น Authenticated Users หรือ Domain Users group จะดีกว่า

นอกจากนี้ควรกำหนด NTFS Permission ที่ Root Drive ให้ Administrator มีสิทธิ Full Controll และเอา User หรือ Group อื่นออก เพิ่อความปลอดภัยและง่ายในการสืบทอดสิทธิในภายหลัง เช่น home directory เป็นต้น

Saturday, November 18, 2006

การใช้ Group Policy Security Filter apply GPO ให้กับ Group หรือ User

โดยปกติแล้ว GPO จะสามารถ apply ได้กับเฉพาะ Local PC, Domain, OU เท่านั้น แต่มีวิธีที่จะทำให้ GPO สามารถ apply ให้กับ Group หรือ User ได้โดยใช้ Group Policy Security Filter เข้ามาช่วย โดยการสร้าง GPO ขึ้นในระดับ Domain แล้วใช้การกำหนดสิทธิให้ Group/User ที่ต้องการบังคับใช้ GPO ให้มีสิทธิ Read, Apply Group Policy

1. เปิด Properties ของ Domain ขึ้นมา ไปที่ tab Group Policy Object กดปุ่ม Properties ของ GPO จะเปิด Windows ใหม่ขึ้นมา ไปที่ Security tab
2. จะเห็น Authenticated Users ได้สิทธิเป็น Read and Apply Group Policy ซึ่งจะหมายถึงทุกๆ Users ที่สามารถ Login เข้า Domain สำเร็จ จะโดนบังคับโดย GPO
3. ให้เอา check box Apply Group Policy ของ Authenticated Users ออก ให้มีสิทธิ Read ได้อย่างเดียว
4. add User หรือ Group ที่ต้องการให้ GPO มีผลบังคับใช้เข้าไป ให้มีสิทธิ Read and Apply Group Policy แทน
5. GPO จะ apply ไปบน User หรือ group นั้นเท่านั้น ถึงแม้ว่าจะเป็น Group Policy ที่สร้างขึ้นในระดับ Domain ก็ตาม

Secure Windows 2003 DC

By locking down access to the DC and its files, there are a number of Group Policy settings you should apply. The first set are located under Computer Configuration Windows Settings Security Settings Local Policies

User Rights Assignment
- Allow logon locally - allow only administrative groups i.e. Domain Admins
- Allow logon through Terminal Services - allow only administrative groups i.e. Domain Admin
- Back up files and folders - allow only administrative groups i.e. Domain Admins

Security Options
- Network access: Allow anonymous SID/Name translation - Disabled
- Network access: Do not allow anonymous enumeration of SAM accounts and shares - Enabled
- Network access: Let Everyone permissions apply to anonymous users - Disabled
- Network security: LAN Manager authentication level - Send NTLMv2 response only
- Network security: Do not store LAN Manager hash value on next password change - Enabled

Friday, November 17, 2006

Disable Windows Firewall and System Restore via GPO.

Disable Windows Firewall
เปิด GPO properties ขึ้นมาแล้วไปที่ Computer Configuration/Administrative Template/Network/Network Connection/Windows Firewall/ Domain Profile/Windows Firewall:Protect all Network Connection = disable

Disable System Restore
อยู่ที่ Computer Configuration/Administrative Template/System/System Restore/Turn Off System Restore = Enable และ Turn Off Configuration = Enable

Disable Simple File Sharing by Custom Administrative Template

;Disable Simple File Sharing by Custom Administrative Template

CLASS MACHINE
CATEGORY !!category
CATEGORY !!WindowsExplorer
POLICY !!SimpleFileSharing
KEYNAME "SYSTEM\CurrentControlSet\Control\Lsa"
EXPLAIN !!SimpleFileSharing_Explain

VALUENAME "ForceGuest"
VALUEON NUMERIC 1
VALUEOFF NUMERIC 0

END POLICY
END CATEGORY
END CATEGORY

[strings]
category="Custom Policy Settings"
SimpleFileSharing="Simple File Sharing"
WindowsExplorer="Windows Explorer"
SimpleFileSharing_Explain="Enable to enable Use simple file sharing.Disable to disable Use simple file sharing."

;end

1. save file ให้มีนามสกุลเป็น .adm แล้ว copy ไปใส่ใน folder c:\windows\inf
2. เปิด active directory user and computer ขึ้นมาเพื่อ set GPO ให้กับ OU
3. เปิด Properties ของ GPO ขึ้นมา browse ไปที่ Computer Setting/Administrative Template/ คลิกขวา เลือก Add Remove Template เลือก Add แล้ว Browse ไปที่ .adm ที่สร้างขึ้น
4. จะมี Custom Policy Setting เพิ่มขึ้นมาให้เลือก Enable/Disable Simple File Sharing ได้
5. เปิด Command Promt สั่ง gpupdate /force /target:computer เพื่อสั่งให้ Client มา update policy ใหม่ไป

Note
- Simple File Sharing จะทำ authentication โดยใช้ User = guest
- ถ้า enable simple file sharing จะทำให้มองไม่เห็นแถบ Security สำหรับเอาไว้ set permission ดังนั้นจึงควร disable simple file sharing + disable guest account

Thursday, November 16, 2006

วิธีแก้ W3073 Unable to logon as user. (USER=administrator, EC=logon failure: unknown user name or bad password.)

The W3073 is caused by the ARCserve system account password being incorrect - run up server admin and specify the correct security credentials, stop and start the services by cstop.bat and cstart.bat

Friday, November 10, 2006

การดูรายละเอียดของ User โดยใช้ Acctinfo.dll (thelazyadmin.com)

หา download ได้ฟรีจาก Windows 2003 Resource Kit แล้วสั่ง
regsvr32 %systemroot%\system32\acctinfo.dll
จะทำให้ในแถบ User Properties ของ Active Directory User and Computer มีแถบ Additional Account Info เพิ่มขึ้นมา