<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SpaLinux.com - สปาลีนุกซ์ &#187; Troubleshooting</title>
	<atom:link href="http://spalinux.com/category/troubleshooting/feed" rel="self" type="application/rss+xml" />
	<link>http://spalinux.com</link>
	<description>เพื่อชีวิตที่ผ่อนคลายของคนใช้ลีนุกซ์</description>
	<lastBuildDate>Sat, 12 May 2012 10:38:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>แก้ปัญหา WordPress  อัพโหลดไฟล์ไม่ได้</title>
		<link>http://spalinux.com/2012/05/fix-wordpress-cannot-upload-file</link>
		<comments>http://spalinux.com/2012/05/fix-wordpress-cannot-upload-file#comments</comments>
		<pubDate>Sat, 12 May 2012 10:35:27 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[CentOS 6]]></category>
		<category><![CDATA[Filesystem]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Web Server]]></category>
		<category><![CDATA[upload file error]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=2359</guid>
		<description><![CDATA[หลังจาก ติดตั้ง WordPress บน CentOS 6 เรียบร้อยแล้ว หากเจอปัญหาสามารถโพสต์ข้อความได้ แต่ไม่สามารถอัพโหลด (upload) ไฟล์ เช่นรูป ได้ ตัวอย่างข้อความ error เมื่อ upload file &#8220;Picture-01.jpg&#8221; has failed to upload due to an error Unable to create directory /var/www/html/wordpress/wp-content/uploads/2012/05. Is its parent directory writable by the server? ในที่นี้จะแสดงวิธีการแก้ไขปัญหา สาเหตเป็นเพราะ wordpress ไม่สามารถสร้างไฟล์หรือไดเร็คทอรี เพื่อเก็บไฟล์ที่อัพโหลดได้ โดยดีฟอลต์ wordpress จะสร้างไฟล์ที่อัพโหลดไว้ภายใต้ไดเร็คทอรี wp-content/uploads เทียบกับไดเร็คทอรีที่ติดตั้ง (เช่น /var/www/html/wordpress/) โดยจะแยกย่อยเป็นปี คศ. และเลขเดือนอีกที [...]]]></description>
			<content:encoded><![CDATA[<p>หลังจาก <a title="View Details: ติดตั้ง WordPress บน CentOS 6" href="http://spalinux.com/2012/05/install-wordpress-on-centos-6" rel="bookmark">ติดตั้ง WordPress บน CentOS 6</a> เรียบร้อยแล้ว หากเจอปัญหาสามารถโพสต์ข้อความได้ แต่ไม่สามารถอัพโหลด (upload) ไฟล์ เช่นรูป ได้</p>
<p>ตัวอย่างข้อความ error เมื่อ upload file</p>
<p><span style="color: #ff0000;">&#8220;Picture-01.jpg&#8221; has failed to upload due to an error</span><br />
<span style="color: #ff0000;">Unable to create directory /var/www/html/wordpress/wp-content/uploads/2012/05. Is its parent directory writable by the server?</span></p>
<p>ในที่นี้จะแสดงวิธีการแก้ไขปัญหา</p>
<p><span id="more-2359"></span></p>
<p><a href="http://spalinux.com/wp-content/uploads/2012/05/w31-wordpress-fail-to-upload-due-to-error-unable-to-create-directory.png"><img class="alignnone size-full wp-image-2360" title="w31-wordpress-fail-to-upload-due-to-error-unable-to-create-directory" src="http://spalinux.com/wp-content/uploads/2012/05/w31-wordpress-fail-to-upload-due-to-error-unable-to-create-directory.png" alt="" width="834" height="600" /></a></p>
<p>สาเหตเป็นเพราะ wordpress ไม่สามารถสร้างไฟล์หรือไดเร็คทอรี เพื่อเก็บไฟล์ที่อัพโหลดได้</p>
<p>โดยดีฟอลต์ wordpress จะสร้างไฟล์ที่อัพโหลดไว้ภายใต้ไดเร็คทอรี wp-content/uploads เทียบกับไดเร็คทอรีที่ติดตั้ง (เช่น /var/www/html/wordpress/) โดยจะแยกย่อยเป็นปี คศ. และเลขเดือนอีกที</p>
<p>วิธีการแก้ไขปัญหา ต้องสร้างไดเร็คทอรี uploads ขึ้นมา แล้วเปลี่ยนสิทธิ (permission) ให้ wordpress สามารถเขียนได้ หากใช้ Apache เป็นเว็บเซิร์ฟเวอร์รันด้วยชื่อผู้ใช้ apache การเปลี่ยนสิทธิก็คือการอนุญาตให้ apache สามารถเขียน (write) ไดเร็คทอรี uploads ได้นั่นเอง</p>
<p>โดยดีฟอลต์จากการติดตั้ง wordpress จะไม่มีไดเร็คทอรี uploads</p>
<pre>[root@cent6 ~]# <strong>cd /var/www/html/wordpress/wp-content/</strong>
[root@cent6 wp-content]# <strong>ls -l</strong>
total 12
-rw-r--r--. 1 root root   30 May  5  2007 index.php
drwxr-xr-x. 3 root root 4096 Apr 20 21:54 plugins
drwxr-xr-x. 4 root root 4096 Apr 20 21:54 themes</pre>
<p>ใช้คำสั่ง mkdir, chown, chmod สร้างไดเร็คทอรี uploads และเปลี่ยนสิทธิ</p>
<pre>[root@cent6 wp-content]# <strong>mkdir uploads</strong>
[root@cent6 wp-content]# <strong>chown apache uploads/</strong>
[root@cent6 wp-content]# <strong>chmod 700 uploads/</strong>
[root@cent6 wp-content]# <strong>ls -l</strong>
total 16
-rw-r--r--. 1 root   root   30 May  5  2007 index.php
drwxr-xr-x. 3 root   root 4096 Apr 20 21:54 plugins
drwxr-xr-x. 4 root   root 4096 Apr 20 21:54 themes
drwx------. 2 apache root 4096 May 12 16:58 uploads</pre>
<p>ส่วนไดเร็คทอรีย่อย ปีคศ. และเลขเดือน โปรแกรม wordpress จะสร้างขึ้นมาเองอัตโนมัติ</p>
<p>ทดลองโพสต์แล้วอัพโหลดรูปอีกครั้ง</p>
<p><a href="http://spalinux.com/wp-content/uploads/2012/05/w32-upload-success.png"><img class="alignnone size-full wp-image-2361" title="w32-upload-success" src="http://spalinux.com/wp-content/uploads/2012/05/w32-upload-success.png" alt="" width="834" height="651" /></a><br />
ลองดูไฟล์และไดเร็คทอรีที่ถูกสร้างใน uploads</p>
<pre>[root@cent6 wp-content]# <strong>ls -lR uploads/</strong>
uploads/:
total 4
drwx------. 3 apache apache 4096 May 12 17:02 2012

uploads/2012:
total 4
drwx------. 2 apache apache 4096 May 12 17:02 05

uploads/2012/05:
total 36
-rw-------. 1 apache apache 33625 May 12 17:02 Picture-01.jpg</pre>
<p>&nbsp;</p>
<p>หมายเหตุ ออปชั่น &#8216;-R&#8217; ของคำสั่ง ls เป็นการแสดงข้อมูลไฟล์และไดเร็คทอรีย่อยทั้งหมด</p>
<p>&nbsp;</p>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a title="View Details: ติดตั้ง WordPress บน CentOS 6" href="http://spalinux.com/2012/05/install-wordpress-on-centos-6" rel="bookmark">ติดตั้ง WordPress บน CentOS 6</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2012/05/fix-wordpress-cannot-upload-file/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ติดตั้งโปรแกรมเพิ่มบน CentOS 6.2</title>
		<link>http://spalinux.com/2012/04/how-to-install-program-on-centos-6-2</link>
		<comments>http://spalinux.com/2012/04/how-to-install-program-on-centos-6-2#comments</comments>
		<pubDate>Sat, 31 Mar 2012 18:11:42 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[CentOS 6]]></category>
		<category><![CDATA[Filesystem]]></category>
		<category><![CDATA[Linux Installation]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[rpm]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1926</guid>
		<description><![CDATA[หลังจาก ติดตั้ง CentOS 6.2 : เลือกชุดซอฟต์แวร์ที่จะลง แล้ว หากต้องการติดตั้งซอฟต์แวร์หรือโปรแกรมเพิ่มเติม สามารถทำได้ดังนี้ ใส่แผ่นดีวีดีติดตั้ง แล้วใช้คำสั่ง mount เพื่อเรียกดูไฟล์ในแผ่น [root@cent6 ~]# mount /dev/dvd /mnt mount: block device /dev/sr0 is write-protected, mounting read-only ในแผ่นดีวีดีติดตั้ง CentOS 6.2 จะมีโครงสร้างไฟล์และไดเร็คทอรีดังนี้ [root@cent6 ~]# cd /mnt/ [root@cent6 mnt]# ls -l total 658 -rw-r--r--. 2 root root 14 Dec 16 09:39 CentOS_BuildTag drwxr-xr-x. 3 root root 2048 Dec 11 06:38 [...]]]></description>
			<content:encoded><![CDATA[<p>หลังจาก <a href="http://spalinux.com/2012/03/centos-6-2-installation-select-a-set-of-software-to-install">ติดตั้ง CentOS 6.2 : เลือกชุดซอฟต์แวร์ที่จะลง</a> แล้ว หากต้องการติดตั้งซอฟต์แวร์หรือโปรแกรมเพิ่มเติม สามารถทำได้ดังนี้</p>
<p><span id="more-1926"></span></p>
<p>ใส่แผ่นดีวีดีติดตั้ง แล้วใช้คำสั่ง mount เพื่อเรียกดูไฟล์ในแผ่น</p>
<pre>[root@cent6 ~]# <strong>mount /dev/dvd /mnt</strong>
mount: block device /dev/sr0 is write-protected, mounting read-only</pre>
<p>ในแผ่นดีวีดีติดตั้ง CentOS 6.2 จะมีโครงสร้างไฟล์และไดเร็คทอรีดังนี้</p>
<pre>[root@cent6 ~]# <strong>cd /mnt</strong>/
[root@cent6 mnt]# <strong>ls -l</strong>
total 658
-rw-r--r--. 2 root root 14 Dec 16 09:39 CentOS_BuildTag
drwxr-xr-x. 3 root root 2048 Dec 11 06:38 EFI
-rw-r--r--. 2 root root 212 Dec 15 11:32 EULA
-rw-r--r--. 2 root root 18009 Dec 15 11:38 GPL
drwxr-xr-x. 3 root root 2048 Dec 11 06:38 images
drwxr-xr-x. 2 root root 2048 Dec 11 06:36 isolinux
drwxrwxr-x. 2 500 500 630784 Dec 16 09:43 Packages
-rw-r--r--. 2 root root 1354 Dec 9 19:58 RELEASE-NOTES-en-US.html
drwxr-xr-x. 2 root root 4096 Dec 16 09:46 repodata
-rw-r--r--. 2 root root 1706 Dec 9 19:57 RPM-GPG-KEY-CentOS-6
-rw-r--r--. 2 root root 1730 Dec 9 19:57 RPM-GPG-KEY-CentOS-Debug-6
-rw-r--r--. 2 root root 1730 Dec 9 19:57 RPM-GPG-KEY-CentOS-Security-6
-rw-r--r--. 2 root root 1734 Dec 9 19:57 RPM-GPG-KEY-CentOS-Testing-6
-r--r--r--. 1 root root 3380 Dec 16 09:46 TRANS.TBL</pre>
<p>สำหรับ CentOS และลีนุกซ์ distribution ตระกูล RedHat เช่น RedHat Enterprise หรือ Fedora จะใช้คำสั่ง rpm ในการจัดการการติดตั้งลงโปรแกรม หรือลบโปรแกรมออก</p>
<p>โดยทางคนจัดทำโปรแกรม จะรวมไฟล์ที่ต้องใช้เข้าด้วยกันให้เป็นไฟล์ในรูปแบบ rpm เพื่อง่ายต่อการติดตั้ง</p>
<p>แต่หากโปรแกรมมีหลายส่วนหรือขนาดใหญ่มาก อาจมีการแยกเป็นไฟล์ rpm ย่อยต่างๆ</p>
<p>สำหรับในแผ่นดีวีดีติดตั้ง CentOS 6.2 จะรวมไฟล์ rpm ของโปรแกรมต่างๆ ที่นิยมใช้กัน อยู่ในไดเร็คทอรี Packages</p>
<p>ตัวอย่าง</p>
<pre>[root@cent6 mnt]# <strong>cd Packages/</strong>
[root@cent6 Packages]# <strong>ls -l</strong>
total 4058406
-rw-r--r--. 2 500 500 1437036 Dec 9 02:38 389-ds-base-1.2.9.14-1.el6.x86_64.rpm
-rw-r--r--. 4 500 500 375664 Dec 9 02:37 389-ds-base-libs-1.2.9.14-1.el6.i686.rpm
-rw-r--r--. 2 500 500 370484 Dec 9 02:38 389-ds-base-libs-1.2.9.14-1.el6.x86_64.rpm
-rw-r--r--. 2 500 500 215284 Dec 15 11:28 abrt-2.0.4-14.el6.centos.x86_64.rpm
-rw-r--r--. 2 500 500 95072 Dec 15 11:28 abrt-addon-ccpp-2.0.4-14.el6.centos.x86_64.rpm
-rw-r--r--. 2 500 500 64268 Dec 15 11:28 abrt-addon-kerneloops-2.0.4-14.el6.centos.x86_64.rpm
-rw-r--r--. 2 500 500 58428 Dec 15 11:28 abrt-addon-python-2.0.4-14.el6.centos.x86_64.rpm
-rw-r--r--. 2 500 500 55908 Dec 15 11:28 abrt-cli-2.0.4-14.el6.centos.x86_64.rpm
...</pre>
<p>หากไม่มีไฟล์ rpm ที่ต้องการในแผ่นแรก ลองใส่แผ่นที่สอง ดูใน Packages</p>
<p>แต่ถ้าไม่มีจริงๆ ก็ต้องค้นหา และดาวน์โหลดจากอินเตอร์เน็ต</p>
<p>&nbsp;</p>
<p>ในหลายๆ ครั้ง จะติดตั้งโปรแกรมที่ต้องการได้ จำเป็นต้องติดตั้งโปรแกรมอื่นก่อน เรียกว่าเป็นปัญหา dependencies ถือว่าเป็นข้อเสียของการใช้คำสั่ง rpm เพียงอย่างเดียวเพื่อการติดตั้งโปรแกรม เพราะต้องแก้ปัญหานี้เอง เมื่อเทียบกับการใช้คำสั่ง yum จะช่วยแก้ไขปัญหานี้ แล้วติดตั้งโปรแกรมที่จำเป็นให้กับเราเลย</p>
<p>อย่างไรก็ตาม โดยส่วนตัวผู้เขียนแล้ว ชอบใช้คำสั่ง rpm เพื่อติดตั้งโปรแกรมที่ต้องการ แก้ไขปัญหา และติดตั้งโปรแกรมที่ต้องติดตั้งก่อนเอง แล้วก็เก็บเป็นคู่มือไว้ ว่าต้องติดตั้งไฟล์ rpm อะไรก่อนหน้าหลัง ทั้งนี้เพื่อต้องการศึกษา รู้จักโปรแกรมได้มากขึ้น</p>
<p>&nbsp;</p>
<h4>ตัวอย่างการติดตั้งไฟล์ rpm (install)</h4>
<p>ในที่นี้ขอยกตัวอย่างการติดตั้งโปรแกรม git ซึ่งเป็นโปรแกรมประเภท revision control ที่เริ่มมีการใช้กันค่อนข้างมาก</p>
<p>โดยจะเป็นการติดตั้งจากแผ่นดีวีดีติดตั้งแผ่นที่ 1</p>
<p>ไฟล์ rpm เพื่อจะติดตั้ง git</p>
<pre>[root@cent6 Packages]# <strong>ls -l git*</strong>
-rw-r--r--. 2 500 500 4844240 Jul 6 2011 git-1.7.1-2.el6_0.1.x86_64.rpm</pre>
<p>ใช้คำสั่ง rpm -i ตามด้วยชื่อไฟล์ rpm เพื่อติดตั้ง (install)</p>
<pre>[root@cent6 Packages]# <strong>rpm -i git-1.7.1-2.el6_0.1.x86_64.rpm</strong>
<span style="color: #ff0000;">warning: git-1.7.1-2.el6_0.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY</span>
<span style="color: #ff0000;">error: Failed dependencies</span>:
 perl(Error) is needed by git-1.7.1-2.el6_0.1.x86_64
 perl(Git) is needed by git-1.7.1-2.el6_0.1.x86_64
 perl-Git = 1.7.1-2.el6_0.1 is needed by git-1.7.1-2.el6_0.1.x86_64</pre>
<p>ผลที่ได้จะพบปัญหาสองอย่าง</p>
<ul>
<li>warning &#8230; NOKEY หมายถึงไม่สามารถตรวจสอบความถูกต้องของไฟล์ได้</li>
<li>error: Failed dependencies หมายถึงจะติดตั้งโปรแกรมนี้ได้ ต้องติดตั้งโปรแกรมอื่นก่อน</li>
</ul>
<p>ก่อนอื่นแนะนำให้แก้ไขปัญหาแรกก่อน วิธีการแก้ไขคือต้องติดตั้ง PGP PUBIC KEY เข้าไปในเครื่องก่อน เพื่อใช้ตรวจสอบความถูกต้องของไฟล์ rpm ที่อยู่ในแผ่น</p>
<p>ไฟล์ที่ใช้คือ RPM-GPG-KEY-CentOS-6 อยู่ไดเร็คทอรีนอกสุดของแผ่น ภายใต้ /mnt</p>
<pre>[root@cent6 mnt]# <strong>ls -l RPM-GPG-KEY-CentOS-6</strong>
-rw-r--r--. 2 root root 1706 Dec 9 19:57 RPM-GPG-KEY-CentOS-6</pre>
<p>ใช้คำสั่ง rpm &#8211;import เพื่อติดตั้ง (import) PUBLIC KEY</p>
<pre>[root@cent6 mnt]# rpm --import RPM-GPG-KEY-CentOS-6</pre>
<p>ต้องไม่มี error ใดๆ จากการรัน rpm</p>
<p>ลองติดตั้ง git อีกครั้ง</p>
<pre>[root@cent6 mnt]# <strong>cd Packages/</strong>
[root@cent6 Packages]# <strong>rpm -i git-1.7.1-2.el6_0.1.x86_64.rpm</strong>
<span style="color: #ff0000;">error: Failed dependencies</span>:
 perl(Error) is needed by git-1.7.1-2.el6_0.1.x86_64
 perl(Git) is needed by git-1.7.1-2.el6_0.1.x86_64
 perl-Git = 1.7.1-2.el6_0.1 is needed by git-1.7.1-2.el6_0.1.x86_64</pre>
<p>ข้อความ warning ก็จะหายไป</p>
<p>ส่วนการแก้ไขปัญหา Failed depenencies นั้น ต้องดูเป็นกรณีไป บางครั้่งก็จะขึ้นชื่อไฟล์ rpm ที่ต้องติดตั้งก่อนมาเลย เช่นในตัวอย่างนี้คือ perl-Git</p>
<p>แต่บางครั้งก็ขึ้นชื่อมาเฉยๆ เช่น perl(Error) เราต้องไปหาเองว่าไฟล์นี้ น่าจะอยู่ในไฟล์ rpm ไหน หลายๆ ครั้งก็ต้องค้นหาจาก google.com</p>
<p>เช่น perl(Error) ใช้ google ก็อาจจะค้นหาว่า &#8220;perl(Error) rpm centos 6.2&#8243; เป็นต้น</p>
<p>ลองแก้ไขปัญหาไปซักพัก มีประสบการณ์ก็พอจะเดาออกว่าอยู่ในไฟล์ rpm ไหน</p>
<p>เช่น perl(Error) ก็น่าจะมีไฟล์ perl-Error ลองดูในแผ่น ใช้คำสั่ง ls หาไฟล์ที่มีคำว่า perl-Error (พิมพ์อักษรตัวใหญ่เล็กให้เหมือนกัน)</p>
<pre>[root@cent6 Packages]# <strong>ls -l *perl-Error*</strong>
-rw-r--r--. 2 500 500 29420 Jul 3 2011 perl-Error-0.17015-4.el6.noarch.rpm</pre>
<p>ลองติดตั้งดู</p>
<pre>[root@cent6 Packages]# <strong>rpm -i perl-Error-0.17015-4.el6.noarch.rpm</strong>
[root@cent6 Packages]#</pre>
<p>ติดตั้งสำเร็จ ลองติดตั้ง git อีกครั้ง</p>
<pre>[root@cent6 Packages]# <strong>rpm -i git-1.7.1-2.el6_0.1.x86_64.rpm</strong>
<span style="color: #ff0000;">error: Failed dependencies</span>:
 perl(Git) is needed by git-1.7.1-2.el6_0.1.x86_64
 perl-Git = 1.7.1-2.el6_0.1 is needed by git-1.7.1-2.el6_0.1.x86_64</pre>
<p>สังเกตว่า perl(Error) หายไป แสดงว่าเราติดตั้งไฟล์ rpm ถูกต้อง</p>
<p>ส่วน perl(Git) หรือ perl-Git ก็ลองหาไฟล์ที่มีคำว่า perl-Git ดู</p>
<pre>[root@cent6 Packages]# <strong>ls -l *perl-Git*</strong>
-rw-r--r--. 2 500 500 28264 Jul 6 2011 perl-Git-1.7.1-2.el6_0.1.noarch.rpm</pre>
<p>ลองติดตั้งดู</p>
<pre>[root@cent6 Packages]# <strong>rpm -i perl-Git-1.7.1-2.el6_0.1.noarch.rpm</strong>
<span style="color: #ff0000;">error: Failed dependencies</span>:
 git = 1.7.1-2.el6_0.1 is needed by perl-Git-1.7.1-2.el6_0.1.noarch</pre>
<p>ปัญหาโลกแตก คือจะติดตั้ง git ก็จำเป็นต้องติดตั้ง perl-Git แต่พอลองติดตั้ง perl-Git ก็ฟ้องว่าต้องติดตั้ง git ก่อน</p>
<p>หากเจอปัญหาแบบนี้ ให้พิมพ์ชื่อไฟล์ เรียงกันไปเลย (คั่นด้วยเว้นวรรค)</p>
<pre>[root@cent6 Packages]# <strong>rpm -i git-1.7.1-2.el6_0.1.x86_64.rpm perl-Git-1.7.1-2.el6_0.1.noarch.rpm</strong></pre>
<p>เป็นอันติดตั้งสำเร็จ ลองใช้คำสั่ง git</p>
<pre>[root@cent6 Packages]# <strong>git --version</strong>
git version 1.7.1</pre>
<h4>ตัวอย่างการลบการติดตั้ง rpm (erase)</h4>
<p>หากไม่ต้องการโปรแกรมที่ติดตั้งด้วย rpm แล้ว สามารถลบออก (erase) ด้วยคำสั่ง rpm -e</p>
<p>ตัวอย่างการพยายามลบ rpm ของ git ออก</p>
<p>หมายเหตุ เวลาลบโปรแกรมให้ระบุเฉพาะชื่อโปรแกรมเท่านั้น ไม่ต้องระบุเวอร์ชั่น</p>
<pre>[root@cent6 Packages]# <strong>rpm -e git</strong>
<span style="color: #ff0000;">error: Failed dependencies</span>:
 git = 1.7.1-2.el6_0.1 is needed by (installed) perl-Git-1.7.1-2.el6_0.1.noarch</pre>
<p>ก็จะฟ้องคล้ายๆ กับตอนติดตั้ง แต่การลบจะกลับกันคือ คุณไม่สามารถลบโปรแกรมนี้ออกได้ เพราะโปรแกรมนี้ถูกใช้โดยโปรแกรมอื่นอยู่ (dependencies)</p>
<p>ลองลบ perl-Git ออก</p>
<pre>[root@cent6 Packages]# <strong>rpm -e perl-Git</strong>
<span style="color: #ff0000;">error: Failed dependencies</span>:
 perl(Git) is needed by (installed) git-1.7.1-2.el6_0.1.x86_64
 perl-Git = 1.7.1-2.el6_0.1 is needed by (installed) git-1.7.1-2.el6_0.1.x86_64</pre>
<p>วิธีการแก้ไขปัญหา เหมือนกับตอนติดตั้งคือระบุชื่อโปรแกรมต่อกันไปเลย</p>
<pre>[root@cent6 Packages]# <strong>rpm -e git perl-Git</strong>
[root@cent6 Packages]#</pre>
<p>หากคุณจำได้หรือทำเอกสารตอนติดตั้งไว้ อีกโปรแกรมที่สามารถลบออกได้คือ perl-Error</p>
<pre>[root@cent6 Packages]# rpm -e perl-Error</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2012/04/how-to-install-program-on-centos-6-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>การเรียกดูไฟล์ในแผ่นซีดีรอมหรือดีวีดีบนลีนุกซ์</title>
		<link>http://spalinux.com/2012/03/how-to-view-file-in-cdrom-or-dvd-on-linux</link>
		<comments>http://spalinux.com/2012/03/how-to-view-file-in-cdrom-or-dvd-on-linux#comments</comments>
		<pubDate>Sat, 31 Mar 2012 16:06:15 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[CentOS 6]]></category>
		<category><![CDATA[Filesystem]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux Shell]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[cdrom]]></category>
		<category><![CDATA[dvd]]></category>
		<category><![CDATA[mount]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1943</guid>
		<description><![CDATA[บนลีนุกซ์เมื่อใส่แผ่นซีดีรอมหรือดีวีดีเข้าไปในไดร์ฟแล้ว หากต้องการเรียกดูไฟล์ในแผ่นต้องทำการ mount ตัวไดร์ฟ (/dev) กับไดเร็คทอรีหรือพาธ (path) บนลีนุกซ์ แล้วถึงจะดูไฟล์ภายใต้พาธนี้ได้ หมายเหตุ หากติดตั้งชุดโปรแกรม Desktop Environment เช่น GNOME ด้วย อาจมีโปรแกรมช่วย mount ตัวไดร์ฟโดยอัตโนมัติ (automount) คือเมื่อใส่แผ่นเราก็สามารถเรียกดูไฟล์ในแผ่นได้เลย ถ้าเป็นแบบนี้ก็ไม่จำเป็นต้องใช้คำสั่ง mount หากติดตั้งลีนุกซ์โดยใช้แผ่นแล้ว ส่วนใหญ่จะมีการสร้างลิ้งค์ไฟล์ (soft link) ไว้เป็นชื่อ /dev/cdrom หรือ /dev/dvd ตัวอย่างเช่นหากติดตั้ง CentOS 6.2 จะมี soft link ชี้ไปที่ /dev/sr0 [root@cent6 ~]# ls -l /dev/cdrom lrwxrwxrwx. 1 root root 3 Mar 31 13:45 /dev/cdrom -&#62; sr0 [...]]]></description>
			<content:encoded><![CDATA[<p>บนลีนุกซ์เมื่อใส่แผ่นซีดีรอมหรือดีวีดีเข้าไปในไดร์ฟแล้ว หากต้องการเรียกดูไฟล์ในแผ่นต้องทำการ mount ตัวไดร์ฟ (/dev) กับไดเร็คทอรีหรือพาธ (path) บนลีนุกซ์ แล้วถึงจะดูไฟล์ภายใต้พาธนี้ได้</p>
<p>หมายเหตุ หากติดตั้งชุดโปรแกรม Desktop Environment เช่น GNOME ด้วย อาจมีโปรแกรมช่วย mount ตัวไดร์ฟโดยอัตโนมัติ (automount) คือเมื่อใส่แผ่นเราก็สามารถเรียกดูไฟล์ในแผ่นได้เลย ถ้าเป็นแบบนี้ก็ไม่จำเป็นต้องใช้คำสั่ง mount</p>
<p><span id="more-1943"></span></p>
<p>หากติดตั้งลีนุกซ์โดยใช้แผ่นแล้ว ส่วนใหญ่จะมีการสร้างลิ้งค์ไฟล์ (soft link) ไว้เป็นชื่อ /dev/cdrom หรือ /dev/dvd</p>
<p>ตัวอย่างเช่นหากติดตั้ง CentOS 6.2 จะมี soft link ชี้ไปที่ /dev/sr0</p>
<pre>[root@cent6 ~]# <strong>ls -l /dev/cdrom</strong>
lrwxrwxrwx. 1 root root 3 Mar 31 13:45 /dev/cdrom -&gt; sr0</pre>
<pre>[root@cent6 ~]# <strong>ls -l /dev/dvd</strong>
lrwxrwxrwx. 1 root root 3 Mar 31 13:45 /dev/dvd -&gt; sr0</pre>
<pre>[root@cent6 ~]# <strong>ls -l /dev/sr0</strong>
brw-rw----. 1 root cdrom 11, 0 Mar 31 13:45 /dev/sr0</pre>
<p>เราสามารถใช้คำสั่ง mount ตามด้วยชื่อไดร์ฟ /dev/cdrom หรือ /dev/dvd หรือแม้แต่ /dev/sr0 ก็ได้</p>
<p>เวลา mount ไดร์ฟแบบใช้ชั่วคราวเช่น cdrom หรือ dvd นิยม mount กับพาธ /mnt</p>
<p>ตัวอย่างการ mount ไดร์ฟที่มีแผ่นติดตั้ง CentOS 6.2 แผ่นที่ 1 เข้ากับพาธ /mnt</p>
<pre>[root@cent6 ~]# <strong>mount /dev/dvd /mnt</strong>
mount: block device /dev/sr0 is write-protected, mounting read-only</pre>
<p>เมื่อ mount แล้ว จะไม่สามารถกดปุ่ม eject เพื่อเอาแผ่นออกได้</p>
<p>ตัวอย่างการใช้คำสั่ง ls เพื่อดูไฟล์ในแผ่น</p>
<pre>[root@cent6 ~]# <strong>cd /mnt/</strong>
[root@cent6 mnt]# <strong>ls -l</strong>
total 658
-rw-r--r--. 2 root root 14 Dec 16 09:39 CentOS_BuildTag
drwxr-xr-x. 3 root root 2048 Dec 11 06:38 EFI
-rw-r--r--. 2 root root 212 Dec 15 11:32 EULA
-rw-r--r--. 2 root root 18009 Dec 15 11:38 GPL
drwxr-xr-x. 3 root root 2048 Dec 11 06:38 images
drwxr-xr-x. 2 root root 2048 Dec 11 06:36 isolinux
drwxrwxr-x. 2 500 500 630784 Dec 16 09:43 Packages
-rw-r--r--. 2 root root 1354 Dec 9 19:58 RELEASE-NOTES-en-US.html
drwxr-xr-x. 2 root root 4096 Dec 16 09:46 repodata
-rw-r--r--. 2 root root 1706 Dec 9 19:57 RPM-GPG-KEY-CentOS-6
-rw-r--r--. 2 root root 1730 Dec 9 19:57 RPM-GPG-KEY-CentOS-Debug-6
-rw-r--r--. 2 root root 1730 Dec 9 19:57 RPM-GPG-KEY-CentOS-Security-6
-rw-r--r--. 2 root root 1734 Dec 9 19:57 RPM-GPG-KEY-CentOS-Testing-6
-r--r--r--. 1 root root 3380 Dec 16 09:46 TRANS.TBL</pre>
<p>เมื่อสิ้นสุดการใช้งาน ต้องการเอาแผ่นออกมาจากไดร์ฟ เราต้องออกจากพาธ /mnt ก่อน แล้วใช้คำสั่ง umount ตามด้วยพาธที่ mount ไว้</p>
<pre>[root@cent6 mnt]# <strong>cd ~</strong>
[root@cent6 ~]# <strong>umount /mnt</strong></pre>
<p>หรืออาจใช้คำสั่ง eject เพื่อ umount แล้วสั่งให้ไดร์ฟเอาแผ่นออกด้วย</p>
<pre>[root@cent6 ~]# eject</pre>
<h4>ปัญหาการ umount ไม่ได้</h4>
<p>หากพาธที่ mount แผ่นไว้ ถูกใช้งานอยู่ เช่นมี user เรียกดูไฟล์ภายใต้พาธนี้อยู่ จะไม่สามารถ umount ได้</p>
<pre>[root@cent6 ~]# <strong>mount /dev/dvd /mnt</strong>
mount: block device /dev/sr0 is write-protected, mounting read-only</pre>
<pre>[root@cent6 ~]# <strong>cd /mnt/</strong>
[root@cent6 mnt]#
[root@cent6 mnt]# <strong>umount /mnt</strong>
<span style="color: #ff0000;">umount: /mnt: device is busy.</span>
<span style="color: #ff0000;"> (In some cases useful info about processes that use</span>
<span style="color: #ff0000;"> the device is found by lsof(8) or fuser(1))</span></pre>
<p>หากเราทราบผู้ที่ใช้พาธนี้อยู่ ก็สามารถบอกให้ cd ออกจากพาธได้ แต่ถ้าไม่ทราบ หรือหาไม่เจอ ต้องใช้คำสั่ง fuser เพื่อหาโปรเซสที่เรียกใช้พาธนี้อยู่</p>
<p>ใช้คำสั่ง fuser ตามด้วยพาธที่ mount แผ่นไว้</p>
<pre>[root@cent6 ~]# <strong>fuser /mnt</strong>
/mnt: <span style="color: #0000ff;">1357</span>c</pre>
<p>ตัวเลข 1357 คือ PID ของโปรเซสที่เรียกใช้พาธนี้อยู่ ใช้คำสั่ง ps เพื่อดูว่าโปรเซสนี้คืออะไร</p>
<pre>[root@cent6 ~]# <strong>ps -ef | grep <span style="color: #0000ff;">1357</span></strong>
root <span style="color: #0000ff;">1357</span> 1353 0 13:49 pts/0 00:00:00 -<span style="color: #0000ff;">bash</span></pre>
<p>ในที่นี้ 1357 คือโปรเซส bash มีคนล็อกอินอยู่ที่หน้าจอ TTY pts/0 เราสามารถใช้คำสั่ง w เพื่อดูว่า pts/0 ล็อกอินมาจากที่ไหนได้</p>
<pre>[root@cent6 ~]# w
 15:34:22 up 1:48, 2 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
<span style="color: #0000ff;">root</span> <span style="color: #0000ff;">pts/0 192.168.5.1</span> 13:49 4:42 0.07s 0.07s <span style="color: #0000ff;">-bash</span>
root pts/1 192.168.5.2 15:29 0.00s 0.02s 0.00s w</pre>
<p>จากผลลัพธ์คำสั่ง w จะเป็นว่า pts/0 เป็นการล็อกอินด้วย root จาก 192.168.5.1 เราก็สามารถไปแจ้งเตือนเพื่อให้ออกจากพาธได้</p>
<p>แต่ถ้าลองใช้คำสั่ง ps แล้ว ไม่สามารถหาเจอได้ว่าใครกำลังใช้อยู่ อาจต้อง kill โปรเซสนั้นไป หรือใช้คำสั่ง fuser ตามด้วยออปชั่น &#8216;-k&#8217; เพื่อ kill โปรเซสทั้งหมดที่เรียกพาธอยู่</p>
<pre>[root@cent6 ~]# <strong>fuser /mnt</strong>
/mnt: 1357c</pre>
<pre>[root@cent6 ~]# <strong>fuser -k /mnt</strong>
/mnt: 1357c</pre>
<pre>[root@cent6 ~]# <strong>fuser /mnt</strong></pre>
<pre>[root@cent6 ~]# <strong>umount /mnt</strong></pre>
<p>ก็จะสามารถ umount พาธ แล้วเอาแผ่นออกจากไดร์ฟได้</p>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2012/03/how-to-view-file-in-cdrom-or-dvd-on-linux/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>โหลด mod_dav_svn ไม่สำเร็จ ฟ้องว่า undefined symbol: dav_register_provider</title>
		<link>http://spalinux.com/2011/06/cannot-load-mod_dav_svn-so-undefined-symbol-dav_register_provider</link>
		<comments>http://spalinux.com/2011/06/cannot-load-mod_dav_svn-so-undefined-symbol-dav_register_provider#comments</comments>
		<pubDate>Mon, 13 Jun 2011 17:06:41 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[Web Server]]></category>
		<category><![CDATA[mod_dav_svn]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1381</guid>
		<description><![CDATA[ขอแปะไว้กันลืม และเผื่อมีท่านใด เจอปัญหาเหมือนผมบ้าง หาอยู่นานพอสมควร เพื่อจะพยายามคอนฟิกเก็บข้อมูล subversion (svn) ไว้บน Web Server หลังจากติดตั้ง &#8220;mod_dav_svn&#8221; แล้วพยายาม สตาร์ต httpd ไม่สำเร็จ ดังนี้ [root@repos ~]# service httpd restart Stopping httpd:                                            [FAILED] Starting httpd: httpd: Syntax error on line 210 of /etc/httpd/conf/httpd.conf: Syntax error on line 2 of /etc/httpd/conf.d/subversion.conf: Cannot load /etc/httpd/modules/mod_dav_svn.so into server: /etc/httpd/modules/mod_dav_svn.so: undefined symbol: dav_register_provider                                                           [FAILED] ไฟล์คอนฟิก &#8220;/etc/httpd/conf.d/subversion.conf&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>ขอแปะไว้กันลืม และเผื่อมีท่านใด เจอปัญหาเหมือนผมบ้าง หาอยู่นานพอสมควร เพื่อจะพยายามคอนฟิกเก็บข้อมูล subversion (svn) ไว้บน Web Server</p>
<p>หลังจากติดตั้ง &#8220;mod_dav_svn&#8221; แล้วพยายาม สตาร์ต httpd ไม่สำเร็จ ดังนี้</p>
<pre>[root@repos ~]# <strong>service httpd restart
</strong>Stopping httpd:                                            [FAILED]
Starting httpd: httpd: Syntax error on line 210 of /etc/httpd/conf/httpd.conf: Syntax error on line 2 of /etc/httpd/conf.d/subversion.conf: Cannot load</pre>
<pre><span style="color: #ff0000;">/etc/httpd/modules/mod_dav_svn.so into server: /etc/httpd/modules/mod_dav_svn.so: undefined symbol: dav_register_provider
</span><span style="color: #ff0000;">                                                          [FAILED]</span></pre>
<p><span id="more-1381"></span><br />
ไฟล์คอนฟิก &#8220;/etc/httpd/conf.d/subversion.conf&#8221;</p>
<pre>[root@repos ~]# <strong>cat /etc/httpd/conf.d/subversion.conf</strong></pre>
<pre>LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
...</pre>
<p>วิธีการแก้ไขคือ คือต้องเปิดคอนฟิกเพื่อโหลดโมดูล &#8220;dav_fs_module&#8221; โดยแก้ไขในไฟล์คอนฟิก /etc/httpd/conf/httpd.conf</p>
<pre>[root@repos ~]# cat /etc/httpd/conf/httpd.conf</pre>
<pre><span style="color: #0000ff;">LoadModule dav_fs_module modules/mod_dav_fs.so</span></pre>
<p>หลังจากแก้ไข ใช้คำสั่ง service เพื่อรีสตาร์ต httpd อีกครั้ง</p>
<pre>[root@repos ~]# <strong>service httpd restart
</strong>Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]</pre>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2011/06/cannot-load-mod_dav_svn-so-undefined-symbol-dav_register_provider/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>รัน SVN แล้วขึ้น error MKACTIVITY request</title>
		<link>http://spalinux.com/2010/07/svn_error_mkactivity_request</link>
		<comments>http://spalinux.com/2010/07/svn_error_mkactivity_request#comments</comments>
		<pubDate>Mon, 26 Jul 2010 09:51:19 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1140</guid>
		<description><![CDATA[เจอปัญหารัน svn แล้วขึ้น error เลยนำมาแชร์ประสบการณ์ให้อ่าน ตัวอย่างการรัน svn แล้วเกิดปัญหา [user1@client ~]$ svn --username user1 import test_project https://192.168.1.1/svn/test_project/trunk/test_project -m 'init release' svn: Server sent unexpected return value (500 Internal Server Error) in response to MKACTIVITY request for '/repos/test_project/!svn/act/...' คอนฟิกที่ใช้เป็นการรัน svn โดยเขียน อ่าน ไฟล์ repos ผ่านทาง Apache DAV ตัวอย่างคอนฟิกไฟล์ของ Apache เพื่อเก็บ svn repos บนเซิร์ฟเวอร์     &#60;Location /svn&#62;         DAV svn [...]]]></description>
			<content:encoded><![CDATA[<p>เจอปัญหารัน svn แล้วขึ้น error เลยนำมาแชร์ประสบการณ์ให้อ่าน</p>
<p>ตัวอย่างการรัน svn แล้วเกิดปัญหา</p>
<pre>[user1@client ~]$ <strong>svn --username user1 import test_project https://192.168.1.1/svn/test_project/trunk/test_project -m 'init release'
</strong>svn: Server sent unexpected return value (500 Internal Server Error) in response to MKACTIVITY request for '/repos/test_project/!svn/act/...'</pre>
<p>คอนฟิกที่ใช้เป็นการรัน svn โดยเขียน อ่าน ไฟล์ repos ผ่านทาง Apache DAV</p>
<p><span id="more-1140"></span></p>
<p>ตัวอย่างคอนฟิกไฟล์ของ Apache เพื่อเก็บ svn repos บนเซิร์ฟเวอร์</p>
<pre>    &lt;Location /svn&gt;
        DAV svn
        SVNParentPath /var/svn/repos</pre>
<pre>        # Limit write permission to list of valid users.
        &lt;LimitExcept GET PROPFIND OPTIONS REPORT&gt;</pre>
<pre>            # Require SSL connection for password protection.
            # SSLRequireSSL</pre>
<pre>            AuthType Basic
            AuthName "Authorization Realm"
            AuthUserFile /var/svn/.htpasswd
            Require valid-user
        &lt;/LimitExcept&gt;
    &lt;/Location&gt;</pre>
<p>ตรวจสอบ error_log ที่เซิร์ฟเวอร์แล้ว มีข้อความประมาณ &#8220;couldn&#8217;t check user&#8221;</p>
<pre>[root@server ~]# <strong>tail /var/log/httpd/ssl_error_log
</strong>[Mon Jul 26 15:56:08 2010] [crit] [client x.x.x.x] configuration error:  <span style="color: #ff0000;">couldn't check <span style="color: #ff0000;">user</span></span><span style="color: #ff0000;">.  No user file?:</span> /repos/test_project/!svn/act/...</pre>
<p>ตอนแรกนึกว่าเป็นปัญหาเกี่ยวกับ permission ของไฟล์หรือไดเร็คทอรี พยายามแก้อยู่นาน จนกระทั่งเปลี่ยน chmod 777 ก็ยังไม่สามารถแก้ปัญหาได้</p>
<p>ลองแก้ปัญหาอยู่นาน ก็พบว่า ดันไปปิด module &#8220;mod_auth_basic&#8221; ในไฟล์คอนฟิก /etc/httpd/conf/httpd.conf ของ apache เลยทดลองเปิดขึ้นมา</p>
<pre>LoadModule auth_basic_module modules/mod_auth_basic.so</pre>
<p>ลองรัน svn อีกครั้ง ก็ยังขึ้น error เหมือนเดิม แต่ครั้งนี้ error_log ที่เซิร์ฟเวอร์เปลี่ยนไปเป็นบ่นเกี่ยวกับ &#8220;No groups file&#8221;</p>
<pre>[user1@client ~]$ <strong>svn --username user1 import test_project </strong><strong>https://192.168.1.1/svn/test_project/trunk/test_project</strong><strong> -m 'init release'
</strong>svn: Server sent unexpected return value (500 Internal Server Error) in response to MKACTIVITY request for '/repos/test_project/!svn/act/...'</pre>
<pre>[Mon Jul 26 16:30:05 2010] [crit] [client x.x.x.x] configuration error:  <span style="color: #ff0000;">couldn't check access.  No groups file?:</span> /repos/test_project/!svn/act/...</pre>
<p>ลองเปิด/ปิด module ต่างๆ อยู่นาน กระทั่งพบว่าต้องเปิดอีก module หนึ่งคือ &#8220;mod_authz_user&#8221;</p>
<pre>LoadModule authz_user_module modules/mod_authz_user.so</pre>
<p>หลังจากเปิด module ทั้งสองแล้วก็สามารถรัน svn ได้ตามปกติ</p>
<pre>[user1@client ~]$ <strong>svn --username user1 import test_project </strong><strong>https://192.168.1.1/svn/test_project/trunk/test_project</strong><strong> -m 'init'
</strong>Authentication realm: &lt;https://192.168.1.1:443&gt; Authorization Realm
Password for 'user1':
Adding         test_project/index.php</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2008/11/basic_using_subversion">การใช้งาน subversion เบื้องต้น</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2010/07/svn_error_mkactivity_request/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ปัญหาการใช้ SSH Public Key Authentication บน Solaris</title>
		<link>http://spalinux.com/2010/06/ssh_public_key_authentication_problem_on_solaris</link>
		<comments>http://spalinux.com/2010/06/ssh_public_key_authentication_problem_on_solaris#comments</comments>
		<pubDate>Sat, 05 Jun 2010 10:40:51 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[secure shell]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1110</guid>
		<description><![CDATA[พยายามคอนฟิก Public Key Authentication เพื่อ login เข้าสู่เครื่องที่ติดตั้ง Solaris อยู่นาน ก็ไม่สามารถทำได้ แต่ในที่สุดก็สามารถหาปัญหาได้ เลยมาแชร์ประสบการณ์เผื่อจะเป็นประโยชน์ ทดสอบปัญหา เริ่มต้นเพิ่ม user บนเครื่องที่ติดตั้ง Solaris 10 สมมติว่าชื่อ user1 [root@solaris ~]# useradd user1 [root@solaris ~]# id user1 uid=502(user1) gid=1(other) groups=1(other) แก้ไข home ของ user1 ให้อยู่ใน /export/home/ และสร้างไดเร็คทอรี [root@solaris ~]# cat /etc/passwd ... user1:x:502:1::/export/home/user1:/bin/sh [root@solaris ~]# cd /export/home [root@solaris home]# mkdir user1 [root@solaris home]# chown [...]]]></description>
			<content:encoded><![CDATA[<p>พยายามคอนฟิก Public Key Authentication เพื่อ login เข้าสู่เครื่องที่ติดตั้ง Solaris อยู่นาน ก็ไม่สามารถทำได้ แต่ในที่สุดก็สามารถหาปัญหาได้ เลยมาแชร์ประสบการณ์เผื่อจะเป็นประโยชน์</p>
<p><span id="more-1110"></span></p>
<h4>ทดสอบปัญหา</h4>
<p>เริ่มต้นเพิ่ม user บนเครื่องที่ติดตั้ง Solaris 10 สมมติว่าชื่อ user1</p>
<pre>[root@solaris ~]# <strong>useradd user1
</strong>[root@solaris ~]# <strong>id user1
</strong>uid=502(user1) gid=1(other) groups=1(other)</pre>
<p>แก้ไข home ของ user1 ให้อยู่ใน /export/home/ และสร้างไดเร็คทอรี</p>
<pre>[root@solaris ~]# <strong>cat /etc/passwd
</strong>...
user1:x:502:1::<span style="color: #0000ff;">/export/home/user1</span>:/bin/sh</pre>
<pre>[root@solaris ~]# <strong>cd /export/home
</strong>[root@solaris home]# <strong>mkdir user1
</strong>[root@solaris home]# <strong>chown user1 user1/
</strong>[root@solaris home]# <strong>su - user1
</strong>[user1@solaris ~]$ <strong>pwd
</strong>/export/home/user1</pre>
<p>ต้องการให้ admin1 จากเครื่องที่ติดตั้ง linux สามารถ ssh ด้วย public key authentication เป็น user1 บนเครื่อง Solaris ได้</p>
<p>สร้าง public, private key ของ admin1</p>
<pre>[admin1@linux ~]$ <strong>ssh-keygen -t rsa
</strong>Generating public/private rsa key pair.
Enter file in which to save the key (/home/admin1/.ssh/id_rsa):
Created directory '/home/admin1/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/admin1/.ssh/id_rsa.
Your public key has been saved in /home/admin1/.ssh/id_rsa.pub.</pre>
<pre>[admin1@linux ~]$ <strong>cat .ssh/id_rsa.pub
</strong><span style="color: #0000ff;">ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtMbbgeFnn6vEo3IAVh... admin1@linux</span></pre>
<p>copy ไฟล์ id_rsa.pub ของ admin1 ไปใส่ไว้ในไฟล์ authorized_keys ของ user1 บนเครื่อง Solaris</p>
<pre>[user1@solaris ~]$ <strong>cat .ssh/authorized_keys
</strong><span style="color: #0000ff;">ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtMbbgeFnn6vEo3IAVh... admin1@linux</span></pre>
<p>ทดสอบ ssh จากเครื่อง linux</p>
<pre>[admin1@linux ~]$ <strong>ssh -l user1 solaris
</strong>The authenticity of host 'solaris (192.168.1.2)' can't be established.
RSA key fingerprint is ...
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'solaris' (RSA) to the list of known hosts.
Password:</pre>
<p>ขึ้นให้ใส่ password ไม่สามารถ login ด้วย public key authentication ได้</p>
<h4>วิธีการแก้ไขปัญหา</h4>
<p>หลังจากพยายามอยู่นาน ก็พบว่า ssh จะตรวจสอบสถานะ password ของผู้ใช้ด้วย ซึ่งถ้าดูในไฟล์ /etc/shadow จะเห็นว่า user1 จะถูก lock อยู่</p>
<pre>[root@solaris ~]# <strong>cat /etc/shadow
</strong>...
user1:<span style="color: #ff0000;"><strong>*LK*</strong></span>:::::::</pre>
<p>ฟิลด์ที่สองในไฟล์ /etc/shadow คือ encrypted password คำอธิบายจาก man ของ shadow คือ</p>
<pre># <strong>man shadow
</strong>...
     password        An encrypted password for the user generated
                     by crypt(3C), a lock string to indicate that
                     the login is not accessible, or  no  string,
                     which  shows  that  there is no password for
                     the login.</pre>
<pre>                     The lock string is defined as <span style="color: #ff0000;"> *LK*</span>  in  the
                     first four characters of the password field.
...</pre>
<p>การแก้ไขคือ ลบตัวอักษร LK ออก เช่นให้เหลือแต่เครื่องหมาย *</p>
<pre>[root@solaris ~]# <strong>cat /etc/shadow
</strong>...
user1:<span style="color: #ff0000;">*</span>:::::::</pre>
<p>ทดสอบ ssh จากเครื่อง linux อีกครั้ง ก็จะได้ตามที่ต้องการ</p>
<pre>[admin1@linux ~]$ <strong>ssh -l user1 solaris
</strong>[user1@solaris ~]$</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2008/10/ssh_secure_shell_login_using_public_key_authentication">SSH – Secure Shell ล็อกอินด้วย Public Key Authentication</a></li>
<li><a href="http://forums.sun.com/thread.jspa?threadID=5229706" target="_blank">Sun Networking Services and Protocols &#8211; SSH PermitEmptyPasswords with PASSREQ</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2010/06/ssh_public_key_authentication_problem_on_solaris/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>รัน mysql_secure_installation ขึ้น Read-only file system</title>
		<link>http://spalinux.com/2009/07/mysql_secure_installation_error_read-only_file_system</link>
		<comments>http://spalinux.com/2009/07/mysql_secure_installation_error_read-only_file_system#comments</comments>
		<pubDate>Sat, 18 Jul 2009 05:30:20 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=834</guid>
		<description><![CDATA[หลังจากติดตั้ง MySQL แล้ว แนะนำให้รัน mysql_secure_installation เพื่อเปลี่ยนคอนฟิกเริ่มต้นเช่น password ในการเรียกใช้ database แต่ถ้ารันคำสั่งนี้ในขณะที่อยู่ในไดเร็คทอรีที่ไม่สามารถเขียนไฟล์ได้ (read-only) เช่นอยู่ในไดเร็คทอรีที่ mount CD หรือ DVD  จะขึ้น error ตามด้านล่าง [root@fc11-64min Packages]# pwd /media/Packages [root@fc11-64min Packages]# mysql_secure_installation touch: cannot touch `.my.cnf.2100': Read-only file system touch: cannot touch `.mysql.2100': Read-only file system chmod: cannot access `.my.cnf.2100': No such file or directory chmod: cannot access `.mysql.2100': No such [...]]]></description>
			<content:encoded><![CDATA[<p>หลังจากติดตั้ง MySQL แล้ว แนะนำให้รัน mysql_secure_installation เพื่อเปลี่ยนคอนฟิกเริ่มต้นเช่น password ในการเรียกใช้ database</p>
<p>แต่ถ้ารันคำสั่งนี้ในขณะที่อยู่ในไดเร็คทอรีที่ไม่สามารถเขียนไฟล์ได้ (read-only) เช่นอยู่ในไดเร็คทอรีที่ mount CD หรือ DVD  จะขึ้น error ตามด้านล่าง</p>
<pre>[root@fc11-64min Packages]# <strong>pwd</strong>
/media/Packages</pre>
<pre>[root@fc11-64min Packages]# <strong>mysql_secure_installation
</strong><span style="color: #ff0000;">touch: cannot touch `.my.cnf.2100': Read-only file system
touch: cannot touch `.mysql.2100': Read-only file system
chmod: cannot access `.my.cnf.2100': No such file or directory
chmod: cannot access `.mysql.2100': No such file or directory</span></pre>
<pre><span style="color: #ff0000;"><span id="more-834"></span></span></pre>
<pre>NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!</pre>
<pre>In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.</pre>
<pre>Enter current password for root (enter for none):
<span style="color: #ff0000;">/usr/bin/mysql_secure_installation: line 47: .my.cnf.2100: Read-only file system
/usr/bin/mysql_secure_installation: line 48: .my.cnf.2100: Read-only file system
/usr/bin/mysql_secure_installation: line 49: .my.cnf.2100: Read-only file system
/usr/bin/mysql_secure_installation: line 50: .my.cnf.2100: Read-only file system
/usr/bin/mysql_secure_installation: line 41: .mysql.2100: Read-only file system
/usr/bin/mysql_secure_installation: line 42: .mysql.2100: No such file or directory
</span>Enter current password for root (enter for none):
Aborting!</pre>
<pre>Cleaning up...
<span style="color: #ff0000;">rm: cannot remove `.my.cnf.2100': Read-only file system
rm: cannot remove `.mysql.2100': Read-only file system</span></pre>
<p>เหตุผลคือ การรันคำสั่ง mysql_secure_installation มีการเขียนไฟล์ชั่วคราว (temporary file) ขึ้นมาในไดเร็คทอรีปัจจุบันด้วย ดังนั้น ต้องเปลี่ยนไปรันใน path ที่สามารถเขียนไฟล์ได้</p>
<pre>[root@fc11-64min Packages]# <strong>cd ~</strong></pre>
<pre>[root@fc11-64min ~]# <strong>mysql_secure_installation</strong></pre>
<pre>NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!</pre>
<pre>In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.</pre>
<pre>Enter current password for root (enter for none):</pre>
<p>ตัวอย่างไฟล์ชั่วคราวที่ถูกสร้างระหว่างรัน mysql_secure_installation</p>
<pre>[root@fc11-64min ~]# <strong>ls -al .my*
</strong>-rw-------. 1 root root 68 2009-07-18 19:23 .my.cnf.2111
-rw-------. 1 root root  1 2009-07-18 19:23 .mysql.2111</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2009/06/install_mysql_on_fedora_11">ติดตั้ง MySQL บน Fedora 11</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2009/07/mysql_secure_installation_error_read-only_file_system/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>แก้ปัญหาล็อกอิน Secure Shell ช้า</title>
		<link>http://spalinux.com/2009/02/solve_slow_login_secure_shell</link>
		<comments>http://spalinux.com/2009/02/solve_slow_login_secure_shell#comments</comments>
		<pubDate>Sat, 21 Feb 2009 09:52:05 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[SSH]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=465</guid>
		<description><![CDATA[เคยประสบปัญหาในการล็อกอินด้วย secure shell ไปยังเครื่องปลายทางช้าหรือไม่ กว่าที่จะขึ้นให้ใส่ password โดยที่เครื่องปลายทาง (secure shell server) ดูแล้วปกติไม่ได้ทำงานหนักอะไร โหลดของเครื่องก็เป็น 0.00 ตรวจสอบโหลดบนเครื่องปลายทาง ด้วยคำสั่ง uptime [root@ssh-server ~]# uptime  16:02:28 up  1:21,  1 user,  load average: 0.00, 0.00, 0.00 บทความนี้จะเสนอการแก้ไขคอนฟิกของ sshd ซึ่งทำหน้าที่เป็น secure shell server โดยตัวอย่างทดสอบ ssh จากเครื่องชื่อ ssh-client ไปยังเครื่องปลายทางชื่อ ssh-server (192.168.1.1) 1. ปิดการตรวจสอบสิทธิแบบ GSSAPI เริ่มต้นทดสอบใช้คำสั่ง ssh จากเครื่องไคลเอนต์ด้วยออปชั่น -v เพื่อดูรายละเอียดขั้นตอนในการล็อกอินด้วย secure shell ไปยังเครื่องปลายทาง ถ้าสังเกตดูหน้าจอจะค้างตรงบรรทัด ... [...]]]></description>
			<content:encoded><![CDATA[<p>เคยประสบปัญหาในการล็อกอินด้วย secure shell ไปยังเครื่องปลายทางช้าหรือไม่ กว่าที่จะขึ้นให้ใส่ password โดยที่เครื่องปลายทาง (secure shell server) ดูแล้วปกติไม่ได้ทำงานหนักอะไร โหลดของเครื่องก็เป็น 0.00</p>
<p>ตรวจสอบโหลดบนเครื่องปลายทาง ด้วยคำสั่ง uptime</p>
<pre>[root@ssh-server ~]# <strong>uptime</strong>
 16:02:28 up  1:21,  1 user,  load average: 0.00, 0.00, 0.00</pre>
<p>บทความนี้จะเสนอการแก้ไขคอนฟิกของ sshd ซึ่งทำหน้าที่เป็น secure shell server โดยตัวอย่างทดสอบ ssh จากเครื่องชื่อ ssh-client ไปยังเครื่องปลายทางชื่อ ssh-server (192.168.1.1)</p>
<p><span id="more-465"></span></p>
<h4>1. ปิดการตรวจสอบสิทธิแบบ GSSAPI</h4>
<p>เริ่มต้นทดสอบใช้คำสั่ง ssh จากเครื่องไคลเอนต์ด้วยออปชั่น -v เพื่อดูรายละเอียดขั้นตอนในการล็อกอินด้วย secure shell ไปยังเครื่องปลายทาง ถ้าสังเกตดูหน้าจอจะค้างตรงบรรทัด</p>
<pre>...
debug1: Next authentication method: gssapi-with-mic</pre>
<p>ช่วงที่หน้าจอค้าง จะเป็นขั้นตอนการตรวจสอบสิทธิ (user authentication) แบบ GSSAPI ซึ่งถ้าเราไม่ได้ใช้งาน หรือคอนฟิกไว้ สามารถเปลี่ยนคอนฟิกของ sshd เพื่อปิดการตรวจสอบสิทธิแบบนี้ออกไป</p>
<pre>[user1@ssh-client ~]$ <strong>ssh -v 192.168.1.1
</strong>OpenSSH_5.1p1, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.1.1 [192.168.1.1] port 22.
debug1: Connection established.
debug1: identity file /home/user1/.ssh/identity type -1
debug1: identity file /home/user1/.ssh/id_rsa type -1
debug1: identity file /home/user1/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1
debug1: match: OpenSSH_5.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server-&gt;client aes128-cbc hmac-md5 none
debug1: kex: client-&gt;server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024&lt;1024&lt;8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '192.168.1.1' is known and matches the RSA host key.
debug1: Found key in /home/user1/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No credentials cache found</pre>
<pre>debug1: Unspecified GSS failure.  Minor code may provide more information
No credentials cache found</pre>
<pre>debug1: Unspecified GSS failure.  Minor code may provide more information</pre>
<pre>debug1: Next authentication method: publickey
debug1: Trying private key: /home/user1/.ssh/identity
debug1: Trying private key: /home/user1/.ssh/id_rsa
debug1: Trying private key: /home/user1/.ssh/id_dsa
debug1: Next authentication method: password
user1@192.168.1.1's password:
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
[user1@ssh-server ~]$</pre>
<p>แก้ไขคอนฟิกของ ssh-server โดยแก้ออปชั่นของ GSSAPI ดังนี้</p>
<pre>[root@ssh-server ssh]# <strong>cat /etc/ssh/sshd_config
</strong>...
# GSSAPI options
<strong>GSSAPIAuthentication no
GSSAPICleanupCredentials no
</strong>...</pre>
<p>หลังจากแก้ไข ใช้คำสั่ง service เพื่อรีโหลด secure sshd ใหม่อีกครั้ง เพื่อให้คอนฟิกใหม่มีผล</p>
<pre>[root@ssh-server ssh]# <strong>service sshd restart
</strong>Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]
[root@ssh-server ssh]#</pre>
<p>ทดสอบการ ssh อีกครั้งหลังจากปิดคุณสมบัติ GSSAPI บนเซิร์ฟเวอร์ จะเห็นว่าเร็วขึ้นมาก ไม่มีบรรทัดที่เกี่ยวข้องกับ GSSAPI ขึ้นมาอีก</p>
<pre>[user1@ssh-client ~]$ <strong>ssh -v 192.168.1.1
</strong>OpenSSH_5.1p1, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.1.1 [192.168.1.1] port 22.
debug1: Connection established.
debug1: identity file /home/user1/.ssh/identity type -1
debug1: identity file /home/user1/.ssh/id_rsa type -1
debug1: identity file /home/user1/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1
debug1: match: OpenSSH_5.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server-&gt;client aes128-cbc hmac-md5 none
debug1: kex: client-&gt;server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024&lt;1024&lt;8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '192.168.1.1' is known and matches the RSA host key.
debug1: Found key in /home/user1/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/user1/.ssh/identity
debug1: Trying private key: /home/user1/.ssh/id_rsa
debug1: Trying private key: /home/user1/.ssh/id_dsa
debug1: Next authentication method: password
user1@192.168.1.1's password:
[user1@ssh-client ~]$</pre>
<pre> </pre>
<pre>
<h4>2. ปิดการตรวจสอบชื่อ hostname กับ DNS (reverse hostname lookup)</h4>

ดีฟอลต์คอนฟิกของ sshd ที่ติดตั้งกับ Fedora เมื่อมีการล็อกอินเข้ามา เซิร์ฟเวอร์จะพยายามแปลง IP Address ของไคลเอนต์ที่เข้ามาเป็นชื่อ hostname โดยไปถามจาก DNS Server (reverse hostname lookup)

ถ้าเครื่อง ssh-server ไม่สามารถติดต่อกับ DNS Server หรือ ไม่มีข้อมูล IP Address ของเครื่องไคลเอนต์อยู่ใน DNS Server ที่คอนฟิกไว้ การล็อกอินจะค้างไปซักพักตรงบรรทัด
<pre>...
debug1: SSH2_MSG_SERVICE_ACCEPT received</pre>
<p>ตัวอย่างการล็อกอิน</p>
<pre>[user1@ssh-client ~]$ <strong>ssh -v 192.168.1.1
</strong>OpenSSH_5.1p1, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.1.1 [192.168.1.1] port 22.
debug1: Connection established.
debug1: identity file /home/user1/.ssh/identity type -1
debug1: identity file /home/user1/.ssh/id_rsa type -1
debug1: identity file /home/user1/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1
debug1: match: OpenSSH_5.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server-&gt;client aes128-cbc hmac-md5 none
debug1: kex: client-&gt;server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024&lt;1024&lt;8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '192.168.1.1' is known and matches the RSA host key.
debug1: Found key in /home/user1/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received</pre>
<p>สามารถแก้ไขปัญหานี้ด้วยการปิดคุณสมบัติการตรวจสอบชื่อ hostname จาก IP Address ของไคลเอนต์ โดยแก้ออปชั่นของ UseDNS ให้เป็นค่า no ดังนี้</p>
<pre>[root@ssh-server ssh]# <strong>cat /etc/ssh/sshd_config
</strong>...
<strong>UseDNS no
</strong>...</pre>
<p>หลังจากแก้ไข ใช้คำสั่ง service เพื่อรีโหลด sshd ใหม่อีกครั้ง เพื่อให้คอนฟิกใหม่มีผล</p>
<pre>[root@ssh-server ssh]# <strong>service sshd restart
</strong>Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]
[root@ssh-server ssh]#</pre>
</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2008/10/introduction_to_secure_shell_ssh">แนะนำการใช้งานโปรแกรม Secure Shell (SSH)</a></li>
<li>man sshd_config(5)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2009/02/solve_slow_login_secure_shell/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>การเปลี่ยน IP Address ของ Samba PDC</title>
		<link>http://spalinux.com/2008/10/changing_samba_pdc_ip_address</link>
		<comments>http://spalinux.com/2008/10/changing_samba_pdc_ip_address#comments</comments>
		<pubDate>Sat, 25 Oct 2008 12:14:23 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Samba]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[pdc]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=300</guid>
		<description><![CDATA[บทความนี้จะอธิบายการแก้ไขปัญหาหลังจากเปลี่ยน IP Address ของเครื่องเซิร์ฟเวอร์ที่รัน Samba ทำหน้าที่เป็น Domain Controller หรือ PDC บนลีนุกซ์ ตัวอย่างในบทความนี้จะเป็นการแก้ไขหลังจากเปลี่ยน IP ของเครื่องเซิร์ฟเวอร์จาก 10.1.0.1 ไปเป็น IP ใหม่คือ 192.168.1.1 ของโดเมน SMBLDAP ก่อนการแก้ไข หลังจากที่เปลี่ยน IP Addres ของลีนุกซ์แล้ว โดยอาจใช้คำสั่ง system-config-network หรือใช้คำสั่ง ifconfig โดยตรง ทดลองรัน Samba เพื่อทำหน้าที่ PDC ขึ้นมาใหม่ เครื่องไคลเอนต์จะไม่สามารถ join เข้าโดเมนได้ ปัญหาที่เกิดขึ้น เนื่องมาจาก มีการเก็บข้อมูล IP เก่าว่าเป็น Domain Controller อยู่ ซึ่งสามารถตรวจสอบได้จากไฟล์ /var/log/samba/log.nbmd จะขึ้นข้อความว่า Domain Controller ยังผูกกับ IP เก่าอยู่ [...]]]></description>
			<content:encoded><![CDATA[<p>บทความนี้จะอธิบายการแก้ไขปัญหาหลังจากเปลี่ยน IP Address ของเครื่องเซิร์ฟเวอร์ที่รัน Samba ทำหน้าที่เป็น Domain Controller หรือ PDC บนลีนุกซ์</p>
<p>ตัวอย่างในบทความนี้จะเป็นการแก้ไขหลังจากเปลี่ยน IP ของเครื่องเซิร์ฟเวอร์จาก 10.1.0.1 ไปเป็น IP ใหม่คือ 192.168.1.1 ของโดเมน SMBLDAP</p>
<p><span id="more-300"></span></p>
<h4>ก่อนการแก้ไข</h4>
<p>หลังจากที่เปลี่ยน IP Addres ของลีนุกซ์แล้ว โดยอาจใช้คำสั่ง system-config-network หรือใช้คำสั่ง ifconfig โดยตรง ทดลองรัน Samba เพื่อทำหน้าที่ PDC ขึ้นมาใหม่ เครื่องไคลเอนต์จะไม่สามารถ join เข้าโดเมนได้</p>
<p>ปัญหาที่เกิดขึ้น เนื่องมาจาก มีการเก็บข้อมูล IP เก่าว่าเป็น Domain Controller อยู่ ซึ่งสามารถตรวจสอบได้จากไฟล์ /var/log/samba/log.nbmd จะขึ้นข้อความว่า Domain Controller ยังผูกกับ IP เก่าอยู่</p>
<p>ตัวอย่างการรัน Samba หลังจากเปลี่ยน IP Adddress</p>
<pre>[root@samba-server ~]#<strong> service smb start
</strong>Starting SMB services:                                     [  OK  ]
[root@samba-server ~]#<strong> service nmb start
</strong>Starting NMB services:                                     [  OK  ]</pre>
<p>ตัวอย่างไฟล์ log.nmbd ที่มีปัญหา</p>
<pre>[root@samba-server ~]# <strong>tail -f /var/log/samba/log.nmbd
</strong>[2008/10/25 16:41:02,  0] nmbd/nmbd.c:main(849)
  nmbd version 3.2.3-0.20.fc9 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2008
[2008/10/25 16:41:02,  0] nmbd/asyncdns.c:start_async_dns(155)
  started asyncdns process 2161
[2008/10/25 16:41:02,  0] nmbd/nmbd_logonnames.c:add_logon_names(160)
  add_domain_logon_names:
  Attempting to become logon server for workgroup SMBLDAP on subnet 192.168.1.1
[2008/10/25 16:41:02,  0] nmbd/nmbd_logonnames.c:add_logon_names(160)
  add_domain_logon_names:
  Attempting to become logon server for workgroup SMBLDAP on subnet UNICAST_SUBNET
[2008/10/25 16:41:02,  0] nmbd/nmbd_become_dmb.c:become_domain_master_browser_wins(336)
  become_domain_master_browser_wins:
  Attempting to become domain master browser on workgroup SMBLDAP, subnet UNICAST_SUBNET.
[2008/10/25 16:41:02,  0] nmbd/nmbd_become_dmb.c:become_domain_master_browser_wins(350)
  become_domain_master_browser_wins: querying WINS server from IP 192.168.1.1 for domain master browser name SMBLDAP&lt;1b&gt; on workgroup SMBLDAP
[2008/10/25 16:41:02,  0] nmbd/nmbd_become_dmb.c:become_domain_master_query_success(234)
  become_domain_master_query_success:
 <span style="color: #ff0000;"> There is already a domain master browser at IP 10.1.0.1 for workgroup SMBLDAP registered on subnet UNICAST_SUBNET.
</span>[2008/10/25 16:41:02,  0] nmbd/nmbd_logonnames.c:become_logon_server_success(121)
  become_logon_server_success: Samba is now a logon server for workgroup SMBLDAP on subnet UNICAST_SUBNET
[2008/10/25 16:41:06,  0] nmbd/nmbd_logonnames.c:become_logon_server_success(121)
  become_logon_server_success: Samba is now a logon server for workgroup SMBLDAP on subnet 192.168.1.1
[2008/10/25 16:41:24,  0] nmbd/nmbd_become_lmb.c:become_local_master_stage2(395)
  *****</pre>
<pre>  Samba name server SAMBA-SERVER is now a local master browser for workgroup SMBLDAP on subnet 192.168.1.1</pre>
<pre>  *****
[2008/10/25 16:41:24,  0] libsmb/nmblib.c:send_udp(839)
 <span style="color: #ff0000;"> Packet send failed to 10.1.0.1(137) ERRNO=Network is unreachable
</span>[2008/10/25 16:41:24,  0] nmbd/nmbd_packets.c:send_netbios_packet(160)
 <span style="color: #ff0000;"> send_netbios_packet: send_packet() to IP 10.1.0.1 port 137 failed
</span>[2008/10/25 16:41:24,  0] nmbd/nmbd_nodestatus.c:node_status(87)
 <span style="color: #ff0000;"> node_status: Failed to send packet trying to get node status for name SMBLDAP&lt;1b&gt;, IP address 10.1.0.1</span></pre>
<pre>ใน Samba จะมีการเก็บข้อมูลของโดเมนว่า เครื่องใดทำหน้าที่อะไรบ้างในเน็ตเวิร์ก จะเก็บไว้ในหลายๆ ไฟล์ ไฟล์หนึ่งที่สามารถดูได้อย่างง่ายคือไฟล์ wins.dat</pre>
<p>ตัวอย่างไฟล์ wins.dat</p>
<pre>[root@samba-server ~]# <strong>cat /var/lib/samba/wins.dat</strong>
VERSION 1 0
"SMBLDAP#1e" 1225185500 0.0.0.0 e4R
"SAMBA-SERVER#00" 1225185500 10.1.0.1 192.168.1.1 66R
"SAMBA-SERVER#03" 1225185500 10.1.0.1 192.168.1.1 66R
"SMBLDAP#1b" 1225184635 10.1.0.1 64R
"SAMBA-SERVER#20" 1225185500 10.1.0.1 192.168.1.1 66R
"SMBLDAP#00" 1225185500 0.0.0.0 e4R
"SMBLDAP#1c" 1225185500 10.1.0.1 192.168.1.1 e4R</pre>
<p>จะเห็นได้ว่าไฟล์นี้ยังเก็บข้อมูล IP เก่าอยู่ ทำให้ Samba ทำงานได้ไม่ถูกต้อง</p>
<h4>การแก้ไข Samba หลังจากเปลี่ยน IP Address ของเครื่องเซิร์ฟเวอร์</h4>
<p>ขั้นตอนแรกต้อง stop เซอร์วิส Samba ก่อน ทั้ง smb และ nmb</p>
<p>ตัวอย่างการ stop เซอร์วิส Samba</p>
<pre>[root@samba-server ~]# <strong>service smb stop
</strong>Shutting down SMB services:                                [  OK  ]
[root@samba-server ~]# <strong>service nmb stop
</strong>Shutting down NMB services:                                [  OK  ]</pre>
<p>ลบไฟล์ที่เก็บข้อมูลของโดเมน โดยไฟล์เหล่านี้จะถูกสร้างขึ้นมาใหม่โดยอัตโนมัติหลังจากรันเซอร์วิส Samba อีกครั้ง</p>
<pre>[root@samba-server ~]# <strong>rm -f /var/lib/samba/wins.dat
</strong>[root@samba-server ~]# <strong>rm -f /var/lib/samba/browse.dat</strong>
[root@samba-server ~]# <strong>rm -f /var/lib/samba/gencache.tdb</strong></pre>
<p>รันเซอร์วิส Samba อีกครั้ง</p>
<pre>[root@samba-server ~]#<strong> service smb start
</strong>Starting SMB services:                                     [  OK  ]
[root@samba-server ~]# <strong>service nmb start</strong>
Starting NMB services:                                     [  OK  ]</pre>
<p>ตรวจสอบไฟล์ log.nmbd หลังการแก้ไข</p>
<pre>[root@samba-server ~]# tail -f /var/log/samba/log.nmbd
[2008/10/25 16:46:05,  0] nmbd/nmbd.c:main(849)
  nmbd version 3.2.3-0.20.fc9 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2008
[2008/10/25 16:46:05,  0] nmbd/asyncdns.c:start_async_dns(155)
  started asyncdns process 2269
[2008/10/25 16:46:05,  0] nmbd/nmbd_logonnames.c:add_logon_names(160)
  add_domain_logon_names:
  Attempting to become logon server for workgroup SMBLDAP on subnet 192.168.1.1
[2008/10/25 16:46:05,  0] nmbd/nmbd_logonnames.c:add_logon_names(160)
  add_domain_logon_names:
  Attempting to become logon server for workgroup SMBLDAP on subnet UNICAST_SUBNET
[2008/10/25 16:46:05,  0] nmbd/nmbd_become_dmb.c:become_domain_master_browser_wins(336)
  become_domain_master_browser_wins:
  Attempting to become domain master browser on workgroup SMBLDAP, subnet UNICAST_SUBNET.
[2008/10/25 16:46:05,  0] nmbd/nmbd_become_dmb.c:become_domain_master_browser_wins(350)
  become_domain_master_browser_wins: querying WINS server from IP 192.168.1.1 for domain master browser name SMBLDAP&lt;1b&gt; on workgroup SMBLDAP
[2008/10/25 16:46:05,  0] nmbd/nmbd_logonnames.c:become_logon_server_success(121)
  become_logon_server_success: Samba is now a logon server for workgroup SMBLDAP on subnet UNICAST_SUBNET
[2008/10/25 16:46:05,  0] nmbd/nmbd_become_dmb.c:become_domain_master_stage2(110)
  *****</pre>
<pre>  Samba server SAMBA-SERVER is now a domain master browser for workgroup SMBLDAP on subnet UNICAST_SUBNET</pre>
<pre>  *****
[2008/10/25 16:46:05,  0] nmbd/nmbd_become_dmb.c:become_domain_master_browser_bcast(291)
  become_domain_master_browser_bcast:
  Attempting to become domain master browser on workgroup SMBLDAP on subnet 192.168.1.1
[2008/10/25 16:46:05,  0] nmbd/nmbd_become_dmb.c:become_domain_master_browser_bcast(304)
  become_domain_master_browser_bcast: querying subnet 192.168.1.1 for domain master browser on workgroup SMBLDAP
[2008/10/25 16:46:09,  0] nmbd/nmbd_logonnames.c:become_logon_server_success(121)
  become_logon_server_success: Samba is now a logon server for workgroup SMBLDAP on subnet 192.168.1.1
[2008/10/25 16:46:13,  0] nmbd/nmbd_become_dmb.c:become_domain_master_stage2(110)
  *****</pre>
<pre>  Samba server SAMBA-SERVER is now a domain master browser for workgroup SMBLDAP on subnet 192.168.1.1</pre>
<pre>  *****
[2008/10/25 16:46:27,  0] nmbd/nmbd_become_lmb.c:become_local_master_stage2(395)
  *****</pre>
<pre>  Samba name server SAMBA-SERVER is now a local master browser for workgroup SMBLDAP on subnet 192.168.1.1</pre>
<pre>  *****</pre>
<p>ตรวจสอบไฟล์ wins.dat หลังการแก้ไข</p>
<pre>[root@samba-server ~]#<strong> cat /var/lib/samba/wins.dat
</strong>VERSION 1 0
"SMBLDAP#1e" 1225187165 0.0.0.0 e4R
"SAMBA-SERVER#00" 1225187165 192.168.1.1 66R
"SAMBA-SERVER#03" 1225187165 192.168.1.1 66R
"SMBLDAP#1b" 1225187165 192.168.1.1 64R
"SAMBA-SERVER#20" 1225187165 192.168.1.1 66R
"SMBLDAP#00" 1225187165 0.0.0.0 e4R
"SMBLDAP#1c" 1225187165 192.168.1.1 e4R</pre>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2008/10/changing_samba_pdc_ip_address/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ตรวจสอบสถานะของการ์ดเน็ตเวิร์กบนลีนุกซ์</title>
		<link>http://spalinux.com/2008/09/verify_lan_network_interface_status_on_linux</link>
		<comments>http://spalinux.com/2008/09/verify_lan_network_interface_status_on_linux#comments</comments>
		<pubDate>Sat, 20 Sep 2008 18:51:00 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=187</guid>
		<description><![CDATA[บทความนี้ขอแนะนำการใช้คำสั่ง ethtool บนลีนุกซ์เพื่อตรวจสอบสถานะของการ์ดเน็ตเวิร์กว่าเป็นอย่างไร เช่น สถานะของลิ้งก์ที่เชื่อมต่ออยู่ว่า Up หรือ Down ความเร็ว (speed) ของการเชื่อมต่อเท่าไร ลีนุกซ์ส่วนใหญ่มีคำสั่ง ethtool ติดตั้งมาอยู่แล้ว ไม่จะเป็นต้องติดตั้งเพิ่มแต่อย่างไร ตัวอย่างเวอร์ชั่นของ ethtool ที่ติดตั้งมากับ Fedora 9 [root@server ~]# rpm -q ethtool ethtool-6-1.fc9.x86_64 วิธีการใช้คำสั่ง ethtool การใช้คำสั่ง ethtool ต้องระบุการ์ดเน็ตเวิร์กที่ต้องการตรวจสอบ เช่นตัวอย่างด้านล่างเป็นการตรวจสอบสถานะของการ์ด eth0 [root@server ~]# ethtool eth0 Settings for eth0:         Supported ports: [ TP ]         Supported link modes:   10baseT/Half 10baseT/Full                                 100baseT/Half 100baseT/Full [...]]]></description>
			<content:encoded><![CDATA[<p>บทความนี้ขอแนะนำการใช้คำสั่ง ethtool บนลีนุกซ์เพื่อตรวจสอบสถานะของการ์ดเน็ตเวิร์กว่าเป็นอย่างไร เช่น สถานะของลิ้งก์ที่เชื่อมต่ออยู่ว่า Up หรือ Down ความเร็ว (speed) ของการเชื่อมต่อเท่าไร</p>
<p><span id="more-187"></span></p>
<p>ลีนุกซ์ส่วนใหญ่มีคำสั่ง ethtool ติดตั้งมาอยู่แล้ว ไม่จะเป็นต้องติดตั้งเพิ่มแต่อย่างไร</p>
<p>ตัวอย่างเวอร์ชั่นของ ethtool ที่ติดตั้งมากับ Fedora 9</p>
<pre>[root@server ~]# <strong>rpm -q ethtool
</strong>ethtool-6-1.fc9.x86_64</pre>
<h4>วิธีการใช้คำสั่ง ethtool</h4>
<p>การใช้คำสั่ง ethtool ต้องระบุการ์ดเน็ตเวิร์กที่ต้องการตรวจสอบ เช่นตัวอย่างด้านล่างเป็นการตรวจสอบสถานะของการ์ด eth0</p>
<pre>[root@server ~]# <strong>ethtool eth0
</strong>Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Advertised auto-negotiation: Yes
<span style="color: #339966;">  </span><span style="color: #339966;"><strong>      Speed: 1000Mb/s
</strong>  </span><strong><span style="color: #339966;">      Duplex: Full
</span></strong>        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: g
        Current message level: 0x000000ff (255)
<strong><span style="color: #339966;">        Link detected: yes</span></strong></pre>
<p>ผลลัพธ์ที่ได้แสดงถึงสถานะของการ์ดเน็ตเวิร์กคร่าวๆ ดังนี้</p>
<ul>
<li><span style="color: #339966;"><strong>Link detected: yes</strong>    </span>สถานะการเชื่อมต่อ Up</li>
<li><span style="color: #339966;"><strong>Speed: 1000Mb/s </strong>    </span>เชื่อมต่อที่ความเร็ว 1000Mb/s หรือ Gigabit</li>
<li><span style="color: #339966;"><strong>Duplex: Full</strong>             </span>  สามารถรับส่งข้อความได้แบบ Full Duplex</li>
</ul>
<p>อีกตัวอย่างหนี่ง เป็นการตรวจสอบการ์ดเน็ตเวิร์กที่สถานะการเชื่อมต่อมีปัญหาหรือ Down</p>
<pre>[root@server ~]# <strong>ethtool eth1
</strong>Settings for eth1:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Advertised auto-negotiation: Yes
<strong><span style="color: #ff0000;">        Speed: Unknown! (0)
</span></strong>        Duplex: Half
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: g
        Current message level: 0x000000ff (255)
 <strong><span style="color: #ff0000;">       Link detected: no</span></strong></pre>
<p>ผลลัพธ์ที่ได้คือ</p>
<ul>
<li><span style="color: #ff0000;"><strong>Link detected: no     </strong></span>สถานะการเชื่อมต่อ Down</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2008/09/verify_lan_network_interface_status_on_linux/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

