Linux下如何搭建SAMBA服务器

怎搭建?
2024-12-17 07:00:45
推荐回答(1个)
回答1:

1、相关的文件
samba-common samba服务器的主文件
samba 服务器端的软件
samba-client 客户端的软件
redhat-config-samba 图形界面的配置文件
samba-swat web配置工具
2、步骤
1)安装SAMBA服务器
(1)检测是否安装samba
#rpm -qa | grep samba
(2)安装:将第一张光盘放入光驱
#mount /mnt/cdrom
#cd /mnt/cdrom/RedHat/RPMS
#ls samba*.*
#rpm -ivh samba-common-2.2.7a-7.9.0.i386.rpm
#rpm -ivh samba-2.2.7a-7.9.0.i386.rpm
#rpm -ivh samba-client-2.2.7a-7.9.0.i386.rpm
#cd /
#umount /mnt/cdrom
#eject
2)设置samba的密码文件
(1)成批用户密码文件的生成
#cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd
(2)删除一些无用的shell帐户
#vi /etc/samba/smbpasswd
从1到9。
(3)设置目录和文件的权限
#chown root.root /etc/samba/smbpasswd
#chmod 500 /etc/samba
#chmod 600 /etc/samba/smbpasswd
#ll -d /etc/samba
(4)单个用户设置samba密码
#useradd wujianan
#passwd wujianan
#smbpasswd -a wujianan
3)启动samba服务器
#service smb start
#pstree | grep mbd
#smbclient -L localhost或者IP地址
4)配置samba的共享
#vi /etc/samba/smb.conf
[global]
workgroup = workgroup
server string = samba server
;hosts allow = 192.168.1. 192.168.2. 127.
printcap = /etc/printcap
load prints = yes
printing = cups
;guest account = pcguest
log file = /var/log/samba/%m.log
max log size = 0
安全选项
security = user(share)
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
;interfaces = 192.168.12.2/24 192.168.13.2/24
dns proxy = no
设置每个用户主目录共享
[homes]
comment = Home Directries
browseable = no 不允许浏览共享文件夹
writeable = yes 允许写入
valid users = %s
create mode = 0664
directry mode = 0775
[printers]
comment = All prints
path = /var/spool/samba
browseable = no
printable = yes
[doc]
comment = doc
path = /home/doc
browseable = no
writeable = no或 read only = yes
guest ok = yes
示例:
要求:创建一个共享目录,所有用户都可访问,权限为只读。
#vi /etc/samba/smb.conf
workgroup = workgroup
server string = samba server
netbios name = RH9
dos charset = cp936
unix charset = cp936
secrity = share
[read]
comment = read
path = /home/read
public = yes
guest ok = yes
read only = yes
保存退出
#mkdir /home/read
#service iptables stop
#service smb start
#testparm
\\ip地址
创建一个可写的目录,允许所有用户可写入。
[write]
comment = write
path = /home/write
public = yes
guest ok = yes
writeable = yes
保存退出
#mkdir /home/write
#chmod 777 /home/write
#service iptables stop
#service smb restart
为指定的用户和组访问samba服务器
#useradd mehost
#passwd wujianan
#smbpasswd -a wujianan
#mkdir /var/samba/wujianan
#chown stu1.stu1 /var/samba/wujianan
#vi /etc/samba/smb.conf

security = user

[wujianan]
comment = wujianan
path = /var/samba/wujianan
valid users = wujianan
public = yes
writeable = yes
保存退出
#service smb restart
最简单的电影服务器的配置
#vi /etc/samba/smb.conf
workgroup = workgroup
server string = movies server
guest account = nobody
security = share
client code page = cp936
wins support = yes
[movies]
comment = movies
browseable = yes
writeable = no
path = /movies
guest ok = yes
read only = yes
保存退出
#mkdir /movies
#useradd admin -d movies
#passwd admin
#vi /etc/passwd
admin:x:0:500::/movies:/bin/bash