介绍如何在linux8下配置samba.
Linux8.0下SAMBA的安装及配置 从光盘中找到与SAMBA相关的文件,执行
rpm –ivh samba-common-2.2.5-10
rpm –ivh samba-2.2.5-10
rpm –ivh samba-client-2.2.5-10
然后进入/etc/samba执行vi smb.conf 命令,文件编辑如下:
[global]
workgroup=cbaccess
netbios name=Hello
server string=Hello’s Linux Server
hosts allow=192.168.7. 192.168.1. 192.168.2. 127.
printcap name=/etc/printcap
load printers=yes
printing=bsd
guest account=dragon
log file=/var/log/samba/%m.log
max log size=50
security=user
encrypt passwords=yes
smb passwd file=/etc/samba/smbpasswd
unix password sync=yes
passwd program=/usr/bin/passwd %u
passwd chat=*New*password*%n\n * Retype*new*password*%n\n
passwd:all*authentication*tokens*updated*successfully*
pam password change=yes
obey pam restrictions=yes
socket option=TCP_NODELAY SO_RECVBUF=8192 SO_SNDBUF=8192
interfaces=192.168.7.148/24
dns proxy=no
[homes]
comment=Hello’s Home Directories
browseable=no
writable=yes
valid users=%s
[printers]
comment=All Printers
path=/var/spool/samba
browseable=no
guest ok=yes
writable=no
printable=yes
[public]
comment=Public Stuff
path=/
browseable=yes
guest ok=yes
public=yes
writable=yes
printable=no
write list=@staff
[dragon]
comment=Fred’s Printer
valid users=dragon
path=/home/dragon
printer=dragon_printer
public=no
writable=no
printable=yes
配置完成后执行 chmod a+w / 使整个机器共享
cd /etc/rc.d/init.d
./smb restart
创建一个Linux的用户,
useradd dragon
passwd dragon
smbpasswd –a dragon
成批添加
cat /etc/passwd |mksmbpasswd.sh >/etc/samba/smbpasswd
/usr/sbin/smbd –D
/usr/sbin/nmbd –D
在win9x机器上修改注册表
WinNT: OHKEY_LOCAL_MACHINE\SYSTEM\ Currentcontrolset\Services\Kdr\Parameters
Win98: HKEY_LOCAL_MACHINE\SYSTEM\Currentcontrolset\Services\Vxd\vnetsup
Win2000: HKEY_LOCAL_MACHINE\SYSTEM\Currentcontrolset\Services\LanmanWorkstation\Parameters
在此处追加键值:键名EnablePlainTextpasswd,值类型为DWORD,值1,此目的主要是因为samba无法还原加密口令,使注册不成功,修改后即可。点击网上邻居,添加NETBEUI协议、TCP/IP协议、Microsoft网络用户,如果使用了DNS要键入DNS的IP地址。从控制面板中点击用户,添加一个Linux中存在的用户,保持与Linux系统中的用户和密码一致,重启计算机,以Linux用户登录即可看到Linux机器。
执行netstat –A 192.168.7.148(或主机名)
在Linux机器上执行
smbclient –L //server
smbclient \\\\server\\共享目录
可访问win9x 资源,但不能 copy.
创建一个目录 /mnt/smb,执行
smbmount \\\\server\\共享目录 /mnt/smb
可访问win9x 资源,并能执行cp 命令。
Smbumount /mnt/smb 挂点失败。
如果想Linux启动后win9x机器就能看到,须作如下处理:
配置 /etc/rc.d/init.d/smb脚本,配置文件如下:
# ! /bin/sh
#
# chkconfig: -91 35
# description:starts and stops the samba smbd and nmbd daemons\
# used to provide SMB network services
#
#pidfile:/var/run/samba/smbd.pid
#pidfile:/var/run/samba/nmbd.pid
#config:/etc/samba/smb.conf
#source function library
if [-f /etc/init.d/functions]: then
./etc/init.d/functions
elif [-f /etc/rc.d/init.d/functions]:then
./etc/rc.d/init.d/functions
else
exit 0
fi
#Avoid using root’s TMPDIR
unset TMPDIR
#source networking configuration
./etc/sysconfig/network
if [-f /etc/sysconfig/samba]:then
./etc/sysconfig/samba
fi
#check that networking is up
[${NETWORKING}=”no”]&& exit 0
#check that smb.conf exists
[-f /etc/samba/sb.conf] || exit 0
#check that we can write to it …so non-root users stop her
[-w /etc/samba/smb.conf] || exit 0
RETVAL=0
start() {
echo –n $”starting SMB services:”
daemon /usr/sbin/smbd –D
RETVAL=$?
echo
echo –n $ “starting NMB services:”
daemon /usr/sbin/nmbd –D
RETVAL2=$?
Echo
[$RETVAL –eq o –a $RETVAL 2 –eq o] && touch /var/lock/subsys/smb || \
RETVAL=1
return $RETVAL
}
stop(){
echo –n $”shutting down SMB services:”
killproc /usr/sbin/smbd
RETVAL=$?
echo
echo –n $”shutting down NMB services:”
killproc /usr/sbin/nmbd
RETVAL2=$?
[$RETVAL –eq 0 –a $RETVAL2 eq 0] && rm –f /var/lock/subsys/smb
echo “”
return $RETVAL
}
restart(){
$0 stop
$0 start
RETVAL=$?
}
reload(){
echo –n $”Reloading smb.conf file:”
killproc –HUP /usr/sbin/smbd
RETVAL=$?
Echo
Return $RETVAL
}
rhstatus(){
status /usr/sbin/smbd
status /usr/sbin/nmbd
RETVAL=$?
}
case “$1” in
start)
start
::
stop)
stop
::
restart)
restart
::
reload)
reload
::
status)
rhstatus
::
condrestart)
[-f /var/lock/subsys/smb] && restart || :
::
*)
echo $ “Usage:$0{start|stop|restart|reload|status|condrestart}”
exit 1
esac
exit $?
然后在命令行下执行
chmod 700 /etc/rc.d/init.d/smb
chkconfig --add smb
chkconfig --level 345 smb on
配置 /etc/pam.d/samba 文件添加:
Auth required /lib/security/pam_pwdb.so nullok shadow
Account required /lib/security/pam_pwdb.so
配置 /etc/logrotate.d/samba文件
/var/log/samba/log.nmdb{
notifempty
missingok
postrotate
/usr/bin/killall –HUP nmbd
endrotate
}
/var/log/samba/log.smbd{
notifempty
missingok
postrotate
/usr/bin/killall –HUP smbd
endrotate
}
查看本文来源