1. 在Redhat中,默认只安装Samba客户端,Samba服务端是默认不安装的,需要手动安装。
下载Samba(http://www.samba.org/samba/ftp/stable/samba-3.5.8.tar.gz
2.安装Samba
#cd samba-3.5.8/source3 //source3目录里是samba-3.x的源文件,source4目录里是samba-4.x的源文件
#./configure --prefix=/usr/local/samba
#make
#make install
3.配置动态链接库路径
# vi /etc/ld.so.conf
添加:/usr/local/samba/lib
# ldconfig //执行ldconfig让配置生效
4. Samba的配置文件位于/usr/local/samba/lib
#cp .../samba-3.5.8/examples/smb.conf.default /usr/local/samba/lib/smb.conf
#vi /usr/local/samba/lib/smb.conf
[global]
workgroup=WORKGROUP //定义Samba所在的工作组或者域
server string=linux //Samba服务器的描述
security=user //安全级别
encrypt passwords = yes
passdb backend = smbpasswd
smb passwd file = /etc/samba/smbpasswd
username map = /etc/samba/smbusers
client lanman auth = yes //这时既可以用smbclient连接,也可以用mount挂载,还可以通过gnome里面的“连接到服务器“来连接,不加会初心lanman认证错误
[share]
comment=samba share
#共享的路径
path=/home/share
public=yes
writeable=yes
5.配置完成后运行testparm检查配置是否正确
#/usr/local/samba/bin/testparm
6.打开端口
#vi /etc/sysconfig/iptables
添加
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
# cp /usr/local/samba/sbin/nmbd /usr/bin/
#!/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 1
fi
unset TMPDIR
. /etc/sysconfig/network
. /etc/sysconfig/samba
fi
[ ${NETWORKING} = "no" ] && exit 1
[ -f /etc/samba/smb.conf ] || exit 6
KIND="SMB"
echo -n $"Starting $KIND services: "
daemon smbd $SMBDOPTIONS
RETVAL=$?
echo
KIND="NMB"
echo -n $"Starting $KIND services: "
daemon nmbd $NMBDOPTIONS
RETVAL2=$?
echo
[ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \
RETVAL=1
return $RETVAL
}
KIND="SMB"
echo -n $"Shutting down $KIND services: "
killproc smbd
RETVAL=$?
echo
KIND="NMB"
echo -n $"Shutting down $KIND services: "
killproc nmbd
RETVAL2=$?
[ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/smb
echo ""
return $RETVAL
}
stop
start
}
echo -n $"Reloading smb.conf file: "
killproc smbd -HUP
RETVAL=$?
echo
return $RETVAL
}
status smbd
RETVAL=$?
status nmbd
RETVAL2=$?
if [ $RETVAL -ne 0 ] ; then
return $RETVAL
fi
if [ $RETVAL2 -ne 0 ] ; then
return $RETVAL2
fi
}
# Allow status as non-root.
if [ "$1" = status ]; then
rhstatus
exit $?
fi
[ -w /etc/samba/smb.conf ] || exit 4
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
;;
status)
rhstatus
;;
condrestart)
[ -f /var/lock/subsys/smb ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}"
exit 2
esac
# chkconfig --list smb
smb 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
# chkconfig --level 3 smb on
# chkconfig --list smb
smb 0:关闭 1:关闭 2:关闭 3:启用 4:关闭 5:关闭 6:关闭
New SMB password:
Retype new SMB password:
Added user lili.