下载地址 (HTTP): http://us1.samba.org/samba/ftp/samba-2.2.8a.tar.bz2 版本: 2.2.8a 软件包大小: 4.4 MB 估计所需硬盘空间: 43 MB 估计编译时间: 5.40 SBU |
Samba软件包为SMB/CIFS客户提供了文件和打印服务。
用下面的命令安装Samba:
注: 从samba-2.2.8a/source目录下安装Samba。
mkdir -p /etc/samba/private && mkdir -p /var/cache/samba && ./configure \ --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var \ --with-piddir=/var/run \ --with-fhs \ --with-smbmount && make && make install && mv /usr/bin/smbmount /usr/bin/mount.smbfs && rm -rf /usr/private && echo "swat 901/tcp" >> /etc/services && echo "swat stream tcp nowait.400 root /usr/sbin/swat swat" >> \ /etc/inetd.conf |
mkdir -p /etc/samba/private mkdir -p /var/cache/samba : |
--prefix=/usr : 将所有的文件路径的前缀改为/usr。
--sysconfdir=/etc : 更改默认的配置文件目录/usr/etc。
--localstatedir=/var : 更改默认的可变数据目录/usr/var。
--with-fhs : 按照FHS标准指定其他文件路径。
--with-smbmount : 创建一个供mount命令使用的额外的执行文件。 这样可以使挂载远程SMB(windows)共享文件系统变得像挂在远程NFS共享文件系统一样容易。
rm -rf /usr/private : 删除在make install期间被 source/scripts/installbin.sh错误创建的目录。
我们将配置一个Samba服务器(SAMBABOX)作为主域控制器,同时配置一个 运行Windows 2000服务器(WIN2KBOX)的域客户端作为此域的成员服务器。 Detailed instructions will be given for adding WIN2KBOX to the domain due to the extra steps necessary. Instructions for adding Windows 95/98/XP clients can be found in the newly installed documentation by pointing a web browser to:
file:///usr/share/samba/swat/using_samba/ch03_01.html#ch03-55770. |
/etc/samba/smb.conf, /etc/rc.d/init.d/samba
首先我们建立一些Samba需要的目录:
mkdir /var/lib/samba && mkdir /var/lib/samba/netlogon && mkdir /var/lib/samba/ntprofile && mkdir /var/lib/samba/profiles && chmod -R 1777 /var/lib/samba |
以及Samba配置文件:
cat > /etc/samba/smb.conf << "EOF" [global] netbios name = SAMBABOX workgroup = DOMAIN01 os level = 64 preferred master = yes domain master = yes local master = yes security = user encrypt passwords = yes domain logons = yes log file = /var/log/log.%m log level = 1 logon path = \\%N\home\%u logon drive = H: logon home = \\homeserver\%u logon script = logon.cmd [netlogon] path = /var/lib/samba/netlogon read only = yes write list = ntadmin [profiles] path = /var/lib/samba/ntprofile read only = no create mask = 0600 directory mask = 0700 ; World writable share for testing [tmp] comment = Temporary file space path = /tmp read only = no public = yes [home] comment = Users' home directories path = /home read only = no public = no EOF |
现在为WIN2KBOX添加机器信任账号:
/usr/sbin/useradd -g 100 -d /dev/null -c \ "machine nickname" -s /bin/false win2kbox$ && passwd -l win2kbox$ && smbpasswd -a -m win2kbox |
创建Samba启动脚本:
cat > /etc/rc.d/init.d/samba << "EOF" #!/bin/bash # Begin $rc_base/init.d/samba # Based on sysklogd script from LFS-3.1 and earlier. # Rewritten by Gerard Beekmans - [email protected] source /etc/sysconfig/rc source $rc_functions case "$1" in start) echo "Starting nmbd..." loadproc /usr/sbin/nmbd -D echo "Starting smbd..." loadproc /usr/sbin/smbd -D ;; stop) echo "Stopping smbd..." killproc /usr/sbin/smbd echo "Stopping nmbd..." killproc /usr/sbin/nmbd ;; reload) echo "Reloading smbd..." reloadproc /usr/sbin/smbd echo "Reloading nmbd..." reloadproc /usr/sbin/nmbd ;; restart) $0 stop sleep 1 $0 start ;; status) statusproc /usr/sbin/nmbd statusproc /usr/sbin/smbd ;; *) echo "Usage: $0 {start|stop|reload|restart|status}" exit 1 ;; esac # End $rc_base/init.d/samba EOF |
添加运行级符号链接:
chmod 754 /etc/rc.d/init.d/samba && ln -s /etc/rc.d/init.d/samba /etc/rc.d/rc0.d/K48samba && ln -s /etc/rc.d/init.d/samba /etc/rc.d/rc1.d/K48samba && ln -s /etc/rc.d/init.d/samba /etc/rc.d/rc2.d/K48samba && ln -s /etc/rc.d/init.d/samba /etc/rc.d/rc3.d/S24samba && ln -s /etc/rc.d/init.d/samba /etc/rc.d/rc4.d/S24samba && ln -s /etc/rc.d/init.d/samba /etc/rc.d/rc5.d/S24samba && ln -s /etc/rc.d/init.d/samba /etc/rc.d/rc6.d/K48samba |
现在,我们将使用新的启动脚本来运行Samba:
/etc/rc.d/init.d/samba start |
为了将WIN2KBOX加入DOMAIN01域,我们必须先在Samba用户列表中添加SAMBABOX的root账号:
smbpasswd -a root |
在启动Samba并在Samba用户列表中添加root账号后, WIN2KBOX将成为我们加入DOMAIN01的第一台机器。 After starting Samba and adding root to the Samba user list, the first machine we'll join to DOMAIN01 will be WIN2KBOX, the Windows 2000 Server box we created the machine trust account for. On WIN2KBOX:
1. Right click on My Computer. 2. Click on Properties. 3. Click on the Network Identification notebook tab. 4. Click on the Properties button. 5. In the Computer Name: edit field enter WIN2KBOX. 6. Click on the Domain: radio button and enter DOMAIN01 in the edit field and click OK. 7. When presented with the Domain Username And Password dialog box, enter root and root's password on SAMBABOX and click OK. 8. After the machine trust is negotiated, click the OK button in the dialog box welcoming you to the DOMAIN01 domain. 9. Click OK in the reboot reminder dialog box. 10. Click OK to close the System Properties window. 11. Click Yes to reboot WIN2KBOX. |
Before logging on to WIN2KBOX, we will create a new user with the following commands:
useradd -m win2kuser01 && passwd win2kuser01 && smbpasswd -a win2kuser01 |
Now we will log on the the domain as our newly created user as follows:
1. Press Ctrl-Alt-Del to bring up the Log On to Windows dialog box. 2. Enter the win2kuser01 name and password. 3. Select DOMAIN01 from the Log on to: combination box and click OK. |
Add the swat entry to /etc/serviceswith the following command:
echo "swat 901/tcp" >> /etc/services |
If inetd is used, the following command will add the swat entry to /etc/inetd.conf:
echo "swat stream tcp nowait.400 root /usr/sbin/swat swat" \ >> /etc/inetd.conf |
If xinetd is used, the following command will add the swat entry to /etc/xinetd.conf:
cat >> /etc/xinetd.conf << "EOF" service swat { port = 901 socket_type = stream wait = no only_from = 127.0.0.1 user = root server = /usr/sbin/swat log_on_failure += USERID } EOF |
The Samba Web Administration Tool, swat, can be launched with the following command on SAMBABOX:
lynx http://localhost:901 |
注: Be sure inetd is running, and issue a killall -HUP inetd before starting swat.
The lynx browser is used in this demonstration, but is not necessary.
cat > /etc/samba/smb.conf << "EOF" : 创建一个默认的Samba配置文件。它可以使Samba作为基于Microsoft Windows网络的主域控制器。 如果你不想使用它,在Samba发行版中捆绑了一个更简单的默认smb.conf文件。参见 samba2.2.8a/examples/smb.conf.default文件。 主域控制器的配置较通常的成员服务器的配置更为复杂。因此这里给出了它的配置方法。
cat > /etc/rc.d/init.d/samba << "EOF" : 创建Samba启动脚本,用于在机器启动和关闭时自动运行和停止Samba。
/usr/sbin/useradd -g 100 -d /dev/null -c \ "Win2k Server" -s /bin/false win2kbox$ : |
echo "swat 901/tcp" >> /etc/services : 注册运行在901端口的swat服务。
echo "swat stream tcp nowait.400 root /usr/sbin/swat swat" >>/etc/inetd.conf : 告知inet在何处查找swat以及如何运行它。
ln -s /etc/rc.d/init.d/samba /etc/rc.d/rc3.d/S600samba, etc.: 创建Samba启动脚本,用于在机器启动和关闭时自动运行和停止Samba。
Samba软件包中包含 make_smbcodepage, make_unicodemap, mount.smbfs, nmbd, nmblookup, rpcclient, smbcacls, smbclient, smbcontrol, smbd, smbpasswd, smbspool, smbstatus, swat, testparm, testprns, wbinfo 以及 winbindd.