linux共享文件夹 redhat_redhat 安装配置samba实现win共享linux主机目录

一、安装前准备1、使用Samba服务器需要防火墙开放以下端口UDP 137 UDP 138 TCP 139 TCP 445#配置防火墙端口[root@roothomes ~] vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT#重启防火墙,使规则生效[root@roothomes ~] /etc/rc.d/init.d/iptables restart2、关闭CentOS6系统的 SELinux[root@roothomes ~] vi /etc/selinux/config#SELINUX=enforcing     #注释掉#SELINUXTYPE=targeted  #注释掉SELINUX=disabled       #增加#:wq  保存。#重启系统[root@roothomes ~] shutdown -r now  或者 init 6二、安装Samba1、检查Samba服务包是否已安装[root@roothomes ~] rpm -qa | grep sambasamba-3.5.4-68.el6.x86_64samba-common-3.5.4-68.el6.x86_64samba-client-3.5.4-68.el6.x86_64samba4-libs-4.0.0-23.alpha11.el6.x86_64samba-winbind-clients-3.5.4-68.el6.x86_64说明samba已经安装,如果没有安装,运行下面命令安装 [root@roothomes ~] yum install samba2、配置samba[root@roothomes ~] chkconfig smb on  #设置 Samba开机自动启动[root@roothomes ~] service smb start      #启动Samba服务[root@roothomes ~] /etc/init.d/smb restart  #重启[root@roothomes ~] /etc/init.d/smb stop    #停止[root@roothomes ~] cp /etc/samba/smb.conf  /etc/samba/bak_smb.conf_bak  #备份[root@roothomes ~] cp /etc/samba/bak_smb.conf_bak  /etc/samba/smb.conf  #恢复[root@roothomes ~] vi /etc/samba/smb.conf[global]                           #找到这一行(全局设置标签),在此行下面添加如下行:workgroup = WORKGROUP          #工作组名称改为 Windows 网络所定义的工作组名server string = Samba Server   #设置samba服务器的主机名称security = user                #设置samba服务器安全级别为user,即以账号和口令访问netbios name = SambaServer     #设置Samba服务器访问别名#在配置文件的末尾添加以下自定义内容[SambaServer]                      #在Windows网上邻居中看到的共享目录的名字comment = SambaServer          #在Windows网上邻居中看到的共享目录的备注信息path = /home/SambaServer       #共享目录在系统中的位置public = no                    #不公开目录writable = yes                 #共享目录可以读写valid users=SambaServer        #只允许SambaServer用户访问#保存配置3、添加访问linux共享目录的账号SambaServer用户家目录为/home/SambaServer, 用户登录终端设为/bin/false(即使之不能登录系统)[root@roothomes ~] mkdir -p /home/SambaServer #建立SambaServer文件夹[root@roothomes ~] cd /home/SambaServer[root@roothomes ~] touch  samba.txt   #创建测试文件samba.txt[root@roothomes ~] useradd SambaServer -d /home/SambaServer -s /bin/false[root@roothomes ~] chown SambaServer:SambaServer /home/SambaServer -R4、将用户SambaServer添加入到Samba用户数据库,并设置登录共享目录的密码为:123456[root@roothomes ~] smbpasswd -a SambaServerNew SMB password:  输入该用户用于登录Samba的密码Retype new SMB password:  再次确认输入该密码Added user SambaServer.#备注:这里设置的密码是SambaServer用户登录该机的Samba共享的密码,非登陆OS的密码;5、重启Samba服务器[root@roothomes ~] /etc/init.d/smb restart6、浏览共享信息在Windows客户端输入 \\ip  或者 \\SambaServer  #服务器别名回车之后,会跳出来登录框,输入账号SambaServer ,密码123456 , 即可访问共享目录问题:如果无法访问共享目录的内容,请把防火墙停止;[root@roothomes ~] service iptables stop

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值