星期二, 8月 26, 2008

利用cygwin 同步 Windows and Linux 伺服器

因為 Windows 還有 Linux的伺服器比較多台
在沒有網域及NIS的狀況底下要同步帳號及密碼
又不想用LDAP

所以就在Window Server上面裝了 cygwin 來執行 Linux的SSH

********************************************************************
在Windows 伺服器上面 ( 要被同步的client)
http://www.cygwin.com/setup.exe
安裝 cygwin

選取從網路安裝, 安裝來源可以選 台大 ( ftp://ftp.ntu.edu.tw)
選取套件
  • Openssh --> 從Net套件安裝
  • diffutils --> 從Utils套件安裝
安裝完畢之後點選桌面上的cygwin 捷徑進入cygwin
輸入
$chmod +r /etc/passwd
$chmod +r /etc/group
$chmod 777 /var
$ssh-host-config

詢問要建立私有權限帳號就答應他吧 ^^

設定好之後, 使用指令啟動 sshd
$net start sshd

接下來要建立個人家目錄內的 .ssh 目錄來存放金鑰
$ssh 127.0.0.1

未必要完成連線, 有這個動作就可以建立 ~/.ssh 目錄了

*******************************************************************

在Linux 伺服器上面
要建立個人家目錄內的 .ssh 目錄來存放金鑰
#ssh 127.0.0.1
未必要完成連線, 有這個動作就可以建立 ~/.ssh 目錄了

#ssh-keygen -d
連續按三下 Enter 鍵建立 DSA的金鑰

#scp ~/.ssh/id_dsa.pub administrator@Windows伺服器的IP:~/.ssh/authorized_keys

這樣以後連線就不需要密碼直接以Key 驗證

建立一個工作資料夾在 /root/lab
#mkdir /root/lab

將Windows Server 的IP 寫在 /root/lab/winserver
內容範例如下
192.168.3.131
192.168.3.134

將Linux Server 的IP 寫在 /root/lab/linuxserver
內容範例如下
192.168.3.136



編寫一個同步的 shell script
#vi syncaccount.sh
#!/bin/bash
# define windows server's ip
echo "****************************************************"
for i in $( cat /root/lab/winserver )
do
echo "Windows server's IP is $i"
done
for q in $( cat /root/lab/linuxserver )
do
echo "Linux server's IP is $q"
done
echo "****************************************************"

echo "Please select your task"
echo "1)to add user account please input --------> useradd"
echo "2)to delete user account please input -----> userdel"
echo "3)to change user's password please input --> passwd"
echo "4)to quit this script please input --------> quit"
echo "please input your choice"

#read the root's task from read
read task

case "$task" in
useradd)
echo "****************************************************"
echo "exec add a user account"
echo "please input user's name"
echo "****************************************************"
read useraddname
echo "****************************************************"
echo "we will add user $useraddname"

for i in $( cat /root/lab/winserver )
do
echo "windows server is $i, add user $useraddname"
ssh administrator@$i "net user $useraddname /add"
done


for q in $( cat /root/lab/linuxserver )
do
echo "Linux server's IP is $q, add user $useraddname"
ssh $q "useradd -m $useraddname"
done
;;
userdel)
echo "****************************************************"
echo "exec del a user account"
echo "please input user's name"
echo "****************************************************"
read userdelname
echo "****************************************************"
echo "we will delete user $userdelname"

for i in $( cat /root/lab/winserver )
do
echo "windows server is $i, del user $userdelname"
ssh administrator@$i "net user $userdelname /delete"
done


for q in $( cat /root/lab/linuxserver )
do
echo "Linux server's IP is $q, del user $userdelname"
ssh $q "userdel -r $userdelname"
done
;;
passwd)
echo "****************************************************"
echo "exec change user's password"
echo "please input user's name"
echo "****************************************************"
read userpasswdname
echo "****************************************************"
echo "please input user's password"
echo "****************************************************"
read userpasswd
echo "we will set user $userpasswdname password"

for i in $( cat /root/lab/winserver )
do
echo "windows server is $i, change user $userpasswdname password"
ssh administrator@$i "net user $userpasswdname $userpasswd"
done


for q in $( cat /root/lab/linuxserver )
do
echo "Linux server's IP is $q, change user $userpasswdname password"
ssh $q "echo $userpasswd |passwd --stdin $userpasswdname"
done
;;
quit)
exit
;;
*)
echo "you type the wrong word"
esac


執行shell script
#sh syncaccount.sh

enjoy it~~~~

星期六, 8月 02, 2008

ifolder3 client on OpenSuSE 11

因為測試的關係
所以在OpenSuSE 11上面裝了
ifolder3 的軟體
解開用戶端軟體之後,
會出現需要xsp需要 gnome-filesystem的相依性問題(因為很懶, 所以用的是 rpm -ivh *.rpm)
套件如下
#ls
ifolder3-3.6.0.7257.1-3.2.i586.rpm simias-1.6.0.7257.1-3.1.i586.rpm
nautilus-ifolder3-3.6.0.7257.1-2.3.i586.rpm xsp-1.2.1-13.8.noarch.rpm

所以就使用偷懶的方法
透過yast2 sw_single先安裝 xsp (他會順便安裝mono)
接下來使用rpm指令安裝 ifolder3, simias, nautilus-ifolder3就可以了
想不到 Linux介面是中文, windows介面反而是英文
^____^

星期六, 7月 12, 2008

Deltaisos in Suse

今天威龍問的問題^__^

找個時間實際 Lab 一下吧

相關Link
http://zh_tw.opensuse.org/%E4%B8%8B%E8%BC%89%E6%8C%87%E5%8D%97

如果您已經有了前一個版本的 ISO 影像檔,Delta ISOs 讓您可以只下載一個小檔案而非重新下載整個 ISO 檔。 deltaiso 包含了新舊版本 iso 的差異。將舊版本的 iso 加上 deltaiso 檔,您就可以得到新的 iso 檔。

要使用這個功能,您需要 deltarpm 這個套件(在 SuSE 中已預設安裝),使用 applydeltaiso 的語法為: applydeltaiso 舊iso deltaiso 新iso

例如: applydeltaiso SUSE-10.0-CD-OSS-i386-Beta1-CD1.iso \
SUSE-10.0-CD-OSS-i386-Beta1_Beta2-CD1.delta.iso \
SUSE-10.0-CD-OSS-i386-Beta2-CD1.iso

如果您已經刪除了前一版本的 ISO 影像檔,別擔心。 applydeltaiso 也可以用在您的光碟片。

例如:如果您有一片 SUSE 10.0-i386 Beta 1 CD 1 在您的光碟機(/dev/hdc)中,

使用以下命令:

applydeltaiso /dev/hdc \
SUSE-10.0-CD-OSS-i386-Beta1_Beta2-CD1.delta.iso \
SUSE-10.0-CD-OSS-i386-Beta2-CD1.iso

然後依照 Checksums 的部份檢查一下 MD5SUMS。加上 Delta ISO 的過程會花上一段時間而且會使用不少硬碟空間來解開 ISO 影像檔。

在 Microsoft Windows 中使用 Applydeltaiso
Windows 所使用的 Applydeltaiso.exe 可以在此下載。

星期日, 6月 29, 2008

Group quota in SuSE Linux

之前套用disk quota都是針對個人做 disk quota
比教少針對 group 作 disk quota

實作上要注意一個小細節是該 Partition要有該群組的檔案
不然之後做 quotacheck的會失去效用

之前的小錯誤就是該filesystem沒有該群組的檔案
就去做quotacheck , 結果就是 edquota 看的到
repquota -ag 以及 quota -g groupname 看到的是none
這種神奇的現象
^^

簡單敘述一下流程
  1. 於/etc/fstab內加入 grpquota選項
  2. mount -o remount 該分割區
  3. quotacheck -gv 該分割區
  4. quotaon -g 該分割區
  5. edquota -g 群組名稱
  6. 開始測試, 並使用 repquota -ag 來觀察

^^

星期五, 6月 27, 2008

解決 VMWare在Notebook鍵盤對應的問題

解決 VMWare在Notebook鍵盤對應的問題
之前有碰到VMWare内的OS如果是在Windows PC上面安裝
把印象檔clone到Notebook上面使用的話, 有鍵盤不能使用或是對應不正確的現象

之前一直以為是鍵盤對應的問題, 所以就不以為意
都很勤勞的把source重作 ^___^

但是這次的debian專案是要把進行到一半的debianOS 移到Notebook上面來做
所以就專心一點處理這個問題

所以一開始的方式是去系統內調整鍵盤的對應
去嘗試 標準鍵盤, 微軟鍵盤都沒有效果.

突然去切換 Ctrl + Alt + F1 想說去切換runlevel 試試看
回到圖形介面就可以了
所以就確定不是鍵盤對應的問題

後來爬了一些文章, 應該是 Num Lock鍵的問題(要關閉才會正常, 預設是開啟)
解決的方式應該有兩個, 自己是使用第一個方式才有效
  • 以Thinkpad來說, Num Lock與Scroll Lock是在同一個按鍵, 所以按Shift + Num Lock按鍵就可以把Num Lock關閉, 就可以正常對應
  • 另外爬文有提到 Shift + Enter 也可以關閉, 但是我試了之後沒用, 先記下來
以後就不用那摩辛苦重新作source了
這個很重要
趕快記下來

星期五, 6月 13, 2008

3COM 3CRWE154G72 on OpenSuSE 10.3

之前有一張3com的PCMCIA網卡
在裝Fedora時候有安裝起來使用(因為那個時候內建的網卡沒抓到)
後來抓到內建的Intel網卡就沒有使用

上次心血來潮在OpenSuSE 上面安裝發現沒有連接
昨天找時間Lab 安裝一下
有看了其他人裝這個套件
p54-kmp-default-20070806_2.6.22.17_0.1-2.1
但是沒有效果^^

後來是把光碟內的Driver 複製到 /lib/firmware
cp /media/3ComWLAN/Driver/3CRWE154G72/3C154G72.arm /lib/firmware/isl3890

一切都ok了 @@

那昨天的熬夜到底算啥
>.<

星期三, 6月 04, 2008

停用compiz設定 in Linux

之前曾經因為豬頭啟用 compiz-fusion導致 X Windos 啟動不正常
所以花費了很多時間
之後爬文, 簡單的解決方式是
#touch ~/.config/compiz/disable-compiz
就不會啟動compiz ^^
趕快把他記起來^^~~~~

星期二, 6月 03, 2008

讓VMWare內的網卡可以執行promiscuous mode

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=287

How do I set my virtual Ethernet adapter on my Linux host to run in promiscuous mode?

VMware software does not allow the virtual Ethernet adapter to go into promiscuous mode unless the user running the VMware software has permission to make that setting. This follows the standard Linux practice that only root can put a network interface into promiscuous mode.

When you install and configure your VMware software, you run the installation as root, and we create the vmnet0-vmnet3 devices with root ownership and root group ownership. We also give those devices read/write access for the owner root only. For a user to be able to set the virtual machine's network adapter to promiscuous mode, the user who launches the VMware product needs to have read/write access to the vmnetx device (/dev/vmnet0 if using basic bridged mode).

One way to do this is to create a new group, add the appropriate users to the group, and give that group read/write access to the appropriate device. These changes need to be made on the host operating system as root (su). For example:

chgrp newgroup /dev/vmnet0
chmod g+rw /dev/vmnet0
where newgroup is the group that should have the ability to set vmnet0 to promiscuous mode.

If you want all users to be able to set the virtual network adapter (/dev/vmnet0 in our example) to promiscuous mode, you can simply run the following command on the host operating system as root:

chmod a+rw /dev/vmnet0

More issues regarding promiscuous mode are discussed in Knowledge Base article 514. Please see:

www.vmware.com/support/kb/enduser/std_adp.php?p_faqid=514.

星期五, 4月 18, 2008

iptables LOG 機制 at SuSE Linux

之前在使用RedHat 系列的Linux時候
在使用 iptabls的時候會使用, 例如
#iptables -A INPUT -p icmp --icmp-type 8 -j LOG
來將ping的動作紀錄起來
以RedHat 系列會去檢查 /var/log/messages

但是由於SuSE Linux使用 syslog-ng的關係
在/etc/syslog-ng/syslog-ng.conf 設定中有把iptables 獨立出來
linux-nb:/var/log # cat /etc/syslog-ng/syslog-ng.conf | grep iptables
filter f_iptables { facility(kern) and match("IN=") and match("OUT="); };
filter f_console { level(warn) and facility(kern) and not filter(f_iptables)
filter f_messages { not facility(news, mail) and not filter(f_iptables); };
filter f_warn { level(warn, err, crit) and not filter(f_iptables); };
# All messages except iptables and the facilities news and mail:
# Firewall (iptables) messages in one file:
log { source(src); filter(f_iptables); destination(firewall); };
# Warnings (except iptables) in one file:

所以有關於iptables的LOG在 SuSE Linux 內
會被儲存在/var/log/firewall

︿︿

星期四, 1月 31, 2008

VMWare 內的滑鼠滾輪功能

在VMWare內使用linux有的時候會發現滑鼠滾輪功能沒有作用
其解決方式為
#vi /etc/X11/xorg.conf
找到滑鼠 protocol那段
Option “Protocol” “ps/2”   
改成   
Option “Protocol” “imps/2"

重新啟動 X就可以使用滑鼠滾輪功能^^