วันอาทิตย์ที่ 29 เมษายน พ.ศ. 2555

Repair ClearOS 5.0

ได้แล้วครับ
เราใช้คำสั่ง
fdisk -l >>> เพื่อดู file system ก่อนครับ ว่าต้องการ ซ่อมแซม ส่วนใหน
fsck /dev/dha? -y >>> ตามด้วย partitions ครับ

ใช่ไม่ใช่ยังงัยก็ขอคำแนะนำด้วยครับ ขอบคุณครับ

วันจันทร์ที่ 16 มกราคม พ.ศ. 2555

secure shell server ช้ามาก

เคยประสบปัญหาในการล็อกอินด้วย 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 ไปยังเครื่องปลายทาง ถ้าสังเกตดูหน้าจอจะค้างตรงบรรทัด



...

debug1: Next authentication method: gssapi-with-mic

ช่วงที่หน้าจอค้าง จะเป็นขั้นตอนการตรวจสอบสิทธิ (user authentication) แบบ GSSAPI ซึ่งถ้าเราไม่ได้ใช้งาน หรือคอนฟิกไว้ สามารถเปลี่ยนคอนฟิกของ sshd เพื่อปิดการตรวจสอบสิทธิแบบนี้ออกไป



[user1@ssh-client ~]$ ssh -v 192.168.1.1 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->client aes128-cbc hmac-md5 none

debug1: kex: client->server aes128-cbc hmac-md5 none

debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<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

debug1: Unspecified GSS failure. Minor code may provide more information

No credentials cache found

debug1: Unspecified GSS failure. Minor code may provide more information

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 ~]$

แก้ไขคอนฟิกของ ssh-server โดยแก้ออปชั่นของ GSSAPI ดังนี้



[root@ssh-server ssh]# cat /etc/ssh/sshd_config ...

# GSSAPI options

GSSAPIAuthentication no GSSAPICleanupCredentials no ...

หลังจากแก้ไข ใช้คำสั่ง service เพื่อรีโหลด secure sshd ใหม่อีกครั้ง เพื่อให้คอนฟิกใหม่มีผล



[root@ssh-server ssh]# service sshd restart Stopping sshd: [ OK ]

Starting sshd: [ OK ]

[root@ssh-server ssh]#

ทดสอบการ ssh อีกครั้งหลังจากปิดคุณสมบัติ GSSAPI บนเซิร์ฟเวอร์ จะเห็นว่าเร็วขึ้นมาก ไม่มีบรรทัดที่เกี่ยวข้องกับ GSSAPI ขึ้นมาอีก



[user1@ssh-client ~]$ ssh -v 192.168.1.1 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->client aes128-cbc hmac-md5 none

debug1: kex: client->server aes128-cbc hmac-md5 none

debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<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 ~]$



2. ปิดการตรวจสอบชื่อ hostname กับ DNS (reverse hostname lookup)



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



ถ้าเครื่อง ssh-server ไม่สามารถติดต่อกับ DNS Server หรือ ไม่มีข้อมูล IP Address ของเครื่องไคลเอนต์อยู่ใน DNS Server ที่คอนฟิกไว้ การล็อกอินจะค้างไปซักพักตรงบรรทัด

...

debug1: SSH2_MSG_SERVICE_ACCEPT received

ตัวอย่างการล็อกอิน

[user1@ssh-client ~]$ ssh -v 192.168.1.1 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->client aes128-cbc hmac-md5 none

debug1: kex: client->server aes128-cbc hmac-md5 none

debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<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

สามารถแก้ไขปัญหานี้ด้วยการปิดคุณสมบัติการตรวจสอบชื่อ hostname จาก IP Address ของไคลเอนต์ โดยแก้ออปชั่นของ UseDNS ให้เป็นค่า no ดังนี้

[root@ssh-server ssh]# cat /etc/ssh/sshd_config ...

UseDNS no ...

หลังจากแก้ไข ใช้คำสั่ง service เพื่อรีโหลด sshd ใหม่อีกครั้ง เพื่อให้คอนฟิกใหม่มีผล

[root@ssh-server ssh]# service sshd restart Stopping sshd: [ OK ]

Starting sshd: [ OK ]

[root@ssh-server ssh]#



ที่มา : http://bunyiam.com/?name=knowledge&file=readknowledge&id=1511

วันพฤหัสบดีที่ 1 ธันวาคม พ.ศ. 2554

Ubuntu 10.04 Samba Standalone Server With tdbsam Backend


Ubuntu 10.04 Samba Standalone Server With tdbsam Backend


1 Preliminary Note

I'm using an Ubuntu 10.04 system here with the hostname server1.example.com and the IP address 192.168.0.100.
I'm running all the steps in this tutorial with root privileges, so make sure you're logged in as root:
sudo su

2 Installing Samba

Connect to your server on the shell and install the Samba packages:
aptitude install libcups2 samba samba-common
Edit the smb.conf file:
vi /etc/samba/smb.conf
In the global section, remove the "#" at the beginning of the line security = user so that it looks like this:
[...]
# "security = user" is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
   security = user
[...]
This enables Linux system users to log in to the Samba server.
Close the file and restart Samba:
/etc/init.d/smbd restart

3 Adding Samba Shares

Now I will add a share that is accessible by all users.
Create the directory for sharing the files and change the group to the users group:
mkdir -p /home/shares/allusers
chown -R root:users /home/shares/allusers/
chmod -R ug+rwx,o+rx-w /home/shares/allusers/
At the end of the file /etc/samba/smb.conf add the following lines:
vi /etc/samba/smb.conf
[...]
[allusers]
  comment = All Users
  path = /home/shares/allusers
  valid users = @users
  force group = users
  create mask = 0660
  directory mask = 0771
  writable = yes
If you want all users to be able to read and write to their home directories via Samba, add the following lines to /etc/samba/smb.conf:
[...]
[homes]
   comment = Home Directories
   browseable = no
   valid users = %S
   writable = yes
   create mask = 0700
   directory mask = 0700
Now we restart Samba:
/etc/init.d/smbd restart

4 Adding And Managing Users

In this example, I will add a user named tom. You can add as many users as you need in the same way, just replace the username tom with the desired username in the commands.
useradd tom -m -G users
Set a password for tom in the Linux system user database. If the user tom should not be able to log in to the Linux system, skip this step.
passwd tom
-> Enter the password for the new user.
Now add the user to the Samba user database:
smbpasswd -a tom
-> Enter the password for the new user.
Now you should be able to log in from your Windows workstation with the file explorer (address is \\192.168.0.100 or \\192.168.0.100\tom for tom's home directory) using the username tom and the chosen password and store files on the Linux server either in tom's home directory or in the public shared directory.


ค่า config


[global]
   security = USER
## Browsing/Identification ###


# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = WORKGROUP
   netbios name = datacenter
# server string is the equivalent of the NT Description field
   server string = %h server (Samba, Ubuntu)




admin users = jason

#   usershare allow guests = yes



[allusers]
  comment = All Users
  path = /home/shares/allusers
  valid users = @users
  force group = users
  create mask = 0660
  directory mask = 0771
  writable = yes

[homes]
   comment = Home Directories
   browseable = no
   valid users = %S
   writable = yes
   create mask = 0700
   directory mask = 0700





วันอังคารที่ 16 มีนาคม พ.ศ. 2553

วันจันทร์ที่ 1 กุมภาพันธ์ พ.ศ. 2553

โฟลเดอร์ ในไดร์ฟ D ถูกHidden

ใช้คำสั่ง Dos ก็ได้ครับ ง่ายดี
เข้า RUN พิมพ์ cmd กด Enter ก่อนนะครับ
จะเข้าโหมดของ Dos ใน วินโดว์ หน้าจอดำ ๆ นั่นแหละ
ยกเลิกการซ่อนทั้งหมดให้พิมพ์
attrib -s -h -r /S /D *.* แล้ว Enter จากนั้นกลับไปสังเกตดูในใดร์ฟ ว่า Folder กลับมาแล้วหรือไม่

ตัวอย่าง โฟลเดอร์ ในไดร์ฟ D ถูกHidden ไว้ ให้เข้าไปที่ D โดยพิมพ์ d: แล้ว Enter
เมื่อ เข้ามาอยู่ใน ไดร์ฟ D แล้ว ให้พิมพ์ attrib -s -h -r /S /D *.* ตาม แล้ว Enter
แล้ว Enter จากนั้นกลับไปสังเกตดูในใดร์ฟ ว่า Folder กลับมาแล้วหรือไม่

- ยกเลิกการซ่อนบาง Folder
attrib -s -h -r /S /D ชื่อโฟลเดอร์
(ไม่จำกัดว่า ชื่อโฟลเดอร์จะเป็นภาษาไทยหรือภาษาอังกฤษ
และชื่อโฟลเดอร์จะต้องไม่เว้นวรรค แต่ถ้ามีให้ทำการแก้ไขชื่อก่อน)

วันพุธที่ 23 ธันวาคม พ.ศ. 2552

วิธีการแก้ Password root ใน Linux กรณีอยู่หน้าเครื่อง

ในกรณี ที่ท่านใช้ GRUB
1. ให้ทำการ Reboot เครื่อง
2. ถ้าท่านตั้ง password ใน GRUB ให้กด p แล้วใส่ Password (ถ้าไม่ได้ตั้ง password ของ GRUB ไว้ให้ทำการข้ามขั้นตอนนี้)
3. ให้เลือก Linux version ที่ท่านต้องการ boot (ในกรณีที่ท่าน ได้ลง linux หลายค่าย หรือ หลาย version )
4. กด e ( เพื่อเข้าไปทำการแก้ไข )
5. ให้กด ลูกศร เพื่อเลื่อนไป บรรทัดที่ขึ้น ต้นคำว่า "kernel" แล้ว พิมพ์ e อีก เพื่อทำการแก้ไข เช่นkernal /vmlinuz-2.4.18.14 ro root=LABEL=/ hdc=ide-scsi
6. ให้เลื่อนไปท้าย สุด แล้ว กด Spacebar เพื่อเว้นวรรค แล้วพิมพ์ "single"จากนั้นให้ กด Enter เพื่อสิ้นสุดการแก้ไข ตัวอย่างkernal /vmlinuz-2.4.18.14 ro root=LABEL=/ hdc=ide-scsi single
7. พิมพ์ b เพื่อ boot แบบ single mode
8. เมื่อ อยู่ ใน single mode ท่านอยู่ในสถานะของ root สามารถ แก้ไข password โดยการใช้คำสั่ง "passwd"
9. ทำการ reboot โดยใช้คำสั่ง "reboot" หรือ "shutdown -r now"

Password root ใช้ GRUB เป็นบูตโหลดเดอร์ ที่ง่ายกว่า
1. ให้ทำการ Reboot เครื่อง
2. เมื่อเครื่องถึงหน้าจอบูตโหลดเดอร์ของ Grub แล้วให้กด ปุ่ม A
3. ให้ไปท้ายคำสั่ง กด Spacebar เพื่อเว้นวรรค แล้วพิมพ์ "single" ต่อท้าย แล้วกด Enter

การเปลี่ยน Password ในกรณีที่ท่านใช้ LILO
1. ให้ทำการ Reboot เครื่อง
2. ถ้าอยู่ในรูปแบบ LILO boot Prompt ให้พิมพ์ "linux single"แต่ถ้าอยู่ในรูปแบบ กราฟฟิค ให้ทำการกด Ctrl-x เพื่อออกจากรูปแบบกราฟฟิคก่อน แล้วพิมพ์ "linux single"
3. เมื่อ อยู่ ใน single mode ท่านอยู่ในสถานะของ root สามารถ แก้ไข password โดยการใช้คำสั่ง "passwd"
4. ทำการ reboot โดยใช้คำสั่ง "reboot" หรือ "shutdown -r now"


ที่มา : http://www.thaiadmin.org/board/index.php?topic=17737.msg89921#msg89921

วันจันทร์ที่ 26 มกราคม พ.ศ. 2552

การติดตั้ง NTP Server

#การติดตั้ง NTP Server (Time Server) ใน ubuntu
#การติดตั้ง NTP Server (Time Server) ใน ubuntuapt-get install ntp
# หรือaptitude install ntp
# config-file จะอยู่ที่ directory /etc/ntp.confvi /etc/ntp.conf
# แก้ไขบรรทัดที่โดยปิด # server ntp.ubuntu.com# แก้ไขเป็นserver time.navy.mi.th dynamicserver clock.thaicert.nectec.or.th prefer
# อัปเดท time แบบแต่ละครั้งntpdate -u time.navy.mi.th# หรือntpdate -u clock.thaicert.nectec.or.th# ผลที่ได้4 Sep 11:32:21 ntpdate[6973]: adjust time server 203.185.129.186 offset -0.004012 sec
# จากนั้น start service ของ ntp ด้วยคำสั่ง/etc/ntp/init.d/ntp restart
# คำสั่งที่เกี่ยวข้อง ntpdate, ntpq# คำสั่งสำหรับตรวจสอบสถานะของ ntpntpq -p# ผลที่ได้remote refid st t when poll reach delay offset jitter==============================================================================*203.185.129.187 .GPS. 1 u 52 64 17 35.624 -34.446 16.013+203.185.69.60 .PPS. 1 u 56 64 17 11.640 -16.548 15.371118-175-67-83.a .PPS. 1 u 57 64 17 53.176 -23.297 48.676time.nist.gov .ACTS. 1 u 58 64 15 254.304 -26.379 2.935
# referid GPS , PPS, ACTS เป็น Stratum 0# st เป็น Stratum 1# reach ต่ำกว่า 377 จะยังไม่ให้เทียบเวลากับที่ร้องขอให้เทียบเวลา
ntpq -p# ผลที่ได้remote refid st t when poll reach delay offset jitter==============================================================================*203.185.129.187 .GPS. 1 u 21 64 377 4.329 -11.303 14.520+203.185.69.60 .PPS. 1 u 21 64 377 12.253 -16.390 7.395+118-175-67-83.a .PPS. 1 u 18 64 375 53.176 -23.297 39.735+time.nist.gov .ACTS. 1 u 21 64 377 254.304 -26.379 17.683
# สามารถให้เครื่องอื่นเทียบเวลาจาก server เราได้
# กำหนดให้เครื่อง client เทียบเวลาจาก server ที่กำหนด# เครื่อง windows แก้ไขที่ time sync
# เครื่อง linux อื่นๆ เพิ่มค่าในcrontab -e
#แก้ไข config ใน crontab# m h dom mon dow command30 */2 * * * /usr/sbin/ntpdate -u 172.19.192.13

ที่มา http://surat.contentbiz.net/?p=58