SAMBA 服务器配置过程
以前在做实验的过程中总结和写的一些教程的一些资料,一直没时间发布到博客上面,五一到了,终于有点时间发布啦!关于Linux上面还会有RHCE系列的学习笔记发表
Samba 服务的安装包:
[root@cisco RPMS]# rpm -qa|grep samba
samba-3.0.10-1.4E
samba-common-3.0.10-1.4E
samba-client-3.0.10-1.4E
samba 的配置文件:/etc/samba/smb.conf
samba 的守护进程:smb nmb
下面用一个具体实例来说明 samba 的配置过程:
要求:1、公司所有的员工都能够在公司内流动办公,但不管在那台电脑上工作,都要把自
己的文件数据保存在 samba 文件服务器上;
2、市场部和技术部都要有各自的目录,同一个部门的人共同拥有一个共享目录,其
他部门的人都只能访问在服务器上自己的个人 home 目录
3、所有用户都不能允许使用服务器上的 shelll
具体案例实施:
1、为所有用户创建账号和目录,不分配 shell.。假设市场部有 tom、jack 两个用户,
技术部有 red、blue,总经理是 ceo
2、创建组 sales和tech,并把相应的用户加入到组中
3、创建两个目录./home/sales 和/home/tech,并且修改两个目录的权限,分别属于 sales
组和 tech 组
4、通过 samba 共享两个文件夹
5、测试
操作步骤:
1、[root@cisco RPMS]# groupadd sales
[root@cisco RPMS]# groupadd tech
[root@cisco RPMS]# vi /etc/passwd
[root@cisco RPMS]# vi /etc/passwd
[root@cisco RPMS]# useradd -g sales -s /bin/false
[root@cisco RPMS]# man false
Formatting page, please wait...
[root@cisco RPMS]# useradd -g sales -s /bin/false tom
[root@cisco RPMS]# useradd -g sales -s /bin/false jack
[root@cisco RPMS]# useradd -g tech -s /bin/false red
[root@cisco RPMS]# useradd -g tech -s /bin/false blue
[root@cisco RPMS]# smbpasswd -a tom
New SMB password:
Retype new SMB password:
startsmbfilepwent_internal: file /etc/samba/smbpasswd did not exist. File successfully created.
Added user tom.
[root@cisco RPMS]# smbpasswd -a jack
New SMB password:
Retype new SMB password:
Mismatch - password unchanged.
www.wqmsl.cnUnable to get new password.
[root@cisco RPMS]# smbpasswd -a jack
New SMB password:
Retype new SMB password:
Added user jack.
[root@cisco RPMS]#
[root@cisco RPMS]# smbpasswd -a red
New SMB password:
Retype new SMB password:
Added user red.
[root@cisco RPMS]# smbpasswd -a blue
New SMB password:
Retype new SMB password:
Added user blue.
[root@cisco RPMS]#
[root@cisco RPMS]# useradd ceo
[root@cisco RPMS]# smbpasswd -a ceo
New SMB password:
Retype new SMB password:
Added user ceo.
[root@cisco RPMS]# cat /etc/samba/smbpasswd
tom:502:67BD2EC1E23AEA8CAAD3B435B51404EE:3ABCFAF9E6F23022460DC080176DFE
9E:[U ]:LCT-4A30CECE:
jack:503:75DB7F84A583EFD9AAD3B435B51404EE:66DADABB531CEADF75FA0CCDB63B
A214:[U ]:LCT-4A30CEE7:
red:504:7B96B77A223162B1AAD3B435B51404EE:2C8A51B3BC2395D6F3623A0B7C4F1CF
A:[U ]:LCT-4A30D580:
blue:505:9095220ABA77AA81AAD3B435B51404EE:505A9279CFD2F94C658980551CFDE73
5:[U ]:LCT-4A30D58B:
ceo:506:422E5EA80C550F9AAAD3B435B51404EE:0A5ECB1958AF159FED0F21FFFD6FBE
C6:[U ]:LCT-4A30D5D3:
[root@cisco RPMS]#
2、[root@cisco ~]# mkdir /home/sales
[root@cisco ~]# mkdir /home/tech
[root@cisco ~]#
[root@cisco ~]# ls -ld /home/sales /home/tech
drwxr-xr-x 2 root root 4096 Jun 12 08:26 /home/sales
drwxr-xr-x 2 root root 4096 Jun 12 08:26 /home/tech
[root@cisco ~]# chgrp sales /home/sales
[root@cisco ~]# chgrp tech /home/tech
[root@cisco ~]# ls -ld /home/sales/ /home/tech/
drwxr-xr-x 2 root sales 4096 Jun 12 08:26 /home/sales/
drwxr-xr-x 2 root tech 4096 Jun 12 08:26 /home/tech/
[root@cisco ~]# chmod 770 /home/sales/ [root@cisco ~]# chmod 770 /home/tech
[root@cisco ~]# ls -ld /home/sales/ /home/tech/
drwxrwx--- 2 root sales 4096 Jun 12 08:26 /home/sales/
drwxrwx--- 2 root tech 4096 Jun 12 08:26 /home/tech/
3、[root@cisco mnt]# vi /etc/samba/smb.conf
[sales]
path=/home/sales
comment=sales file
public=no
valid users=@sales
writable=yes
create mask=0750
directory mask=0750
[tech]
path=/home/tech
comment=tech file
public=no
valid users=@tech
writable=yes
create mask=0750
directory mask=0750
4、测试:可以用 windows 验证
[root@cisco ~]# smbclient -L 192.168.20.1
Password:
Anonymous login successful
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.0.10-1.4E]
Sharename Type Comment
--------- ---- -------
sales Disk sales file
tech Disk tech file
IPC$ IPC IPC Service (Samba Server)
ADMIN$ IPC IPC Service (Samba Server)
Anonymous login successful
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.0.10-1.4E]
Server Comment
--------- -------
CISCO Samba Server
Workgroup Master
--------- -------
MYGROUP CISCO
[root@cisco ~]# smbclient //192.168.20.1/sales -U tom%tom Domain=[CISCO] OS=[Unix] Server=[Samba 3.0.10-1.4E]
smb: \> help
? altname archive blocksize cancel
case_sensitive cd chmod chown del
dir du exit get hardlink
help history lcd link lowercase
ls mask md mget mkdir
more mput newer open print
printmode prompt put pwd q
queue quit rd recurse reget
rename reput rm rmdir setmode
stat symlink tar tarmode translate
vuid logon !
smb: \> quit
[root@cisco ~]#
[root@cisco ~]# mkdir abc
mkdir: cannot create directory `abc': File exists
[root@cisco ~]# ls
abc anaconda-ks.cfg install.log install.log.syslog login.txt
[root@cisco ~]# smbmount //192.168.20.1/sales /root/abc -o username=tom
Password:
[root@cisco ~]# cd /root/abc/
[root@cisco abc]# ls
123.txt aaaa qqqq sales.txt
[root@cisco abc]#
用网页管理 SAMBA
[root@cisco RPMS]# rpm -ivh samba-swat-3.0.10-1.4E.i386.rpm
warning: samba-swat-3.0.10-1.4E.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ########################################### [100%]
1:samba-swat ########################################### [100%]
[root@cisco RPMS]# chkconfig swat on
[root@cisco RPMS]# vi /etc/xinetd.d/swat
[root@cisco RPMS]# cat /etc/xinetd.d/swat
# default: off
# description: SWAT is the Samba Web Admin Tool. Use swat \
# to configure your Samba server. To use SWAT, \
# connect to port 901 with your favorite web browser.
service swat
{
disable = no
port = 901
socket_type = stream
wait = no
only_from = 192.168.20.10 user = root
server = /usr/sbin/swat
log_on_failure += USERID
}
[root@cisco RPMS]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
然后用windows主机登陆即可:http://192.168.20.1:901 用root用户