搭建samba服务
Posted the-day-of-the-wind
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了搭建samba服务相关的知识,希望对你有一定的参考价值。
1. 安装samba 查看自己的服务器中是否安装了samba服务: # rpm -aq|grep samba 没有直接运行以下命令: # yum install samba samba-client samba-swat 运行后,依赖包(samba-common、samba-winbind-clients、libsmbclient)将直接自动安装. 2. 建用户,建共享文件夹并设置文件权限及归属 添加用户: [root@localhost samba]# useradd -s /sbin/nologin devadmin [root@localhost samba]# useradd -s /sbin/nologin testadmin [root@localhost samba]# useradd -s /sbin/nologin uiadmin [root@localhost samba]# useradd -s /sbin/nologin hradmin [root@localhost samba]# useradd -s /sbin/nologin prodadmin [root@localhost samba]# useradd -s /sbin/nologin optsadmin [root@localhost samba]# useradd -s /sbin/nologin admin 添加用户并设置用户所属组: [root@localhost samba]# useradd -g devadmin -s /sbin/nologin d [root@localhost samba]# useradd -g hradmin -s /sbin/nologin h [root@localhost samba]# useradd -g prodadmin -s /sbin/nologin p [root@localhost samba]# useradd -g optsadmin -s /sbin/nologin o 3. 为用户设置samba密码: # smbpasswd -a devadmin New SMB password: Retype new SMB password: Added user devadmin. 4. 新建共享目录: # mkdir company # cd company # mkdir DEV TEST HR share # ll total 0 drwxr-xr-x 2 root root 6 Jun 30 14:26 DEV drwxr-xr-x 2 root root 6 Jun 30 14:26 HR drwxr-xr-x 2 root root 6 Jun 30 14:26 share drwxr-xr-x 2 root root 6 Jun 30 14:26 TEST 设置项目权限: # chown devadmin.devadmin DEV/ && chown hradmin.hradmin HR && chown testadmin.testadmin TEST/ # ll total 0 drwxr-xr-x 2 devadmin devadmin 6 Jun 30 14:26 DEV drwxr-xr-x 2 hradmin hradmin 6 Jun 30 14:26 HR drwxr-xr-x 2 root root 6 Jun 30 14:26 share drwxr-xr-x 2 testadmin testadmin 6 Jun 30 14:26 TEST # chmod -R 0775 share/ # ll | grep share total 0 drwxrwxr-x 2 root root 6 Jun 30 14:26 share # cd share # mkdir DEV HR TEST Tools # chown devadmin.devadmin DEV/ && chown hradmin.hradmin HR && chown testadmin.testadmin TEST/ && chown admin.admin Tools/ # ll total 0 drwxr-xr-x 2 devadmin devadmin 6 Jun 30 14:52 DEV drwxr-xr-x 2 hradmin hradmin 6 Jun 30 14:52 HR drwxr-xr-x 2 testadmin testadmin 6 Jun 30 14:52 TEST drwxr-xr-x 2 admin admin 6 Jun 30 14:52 Tools # chmod 1770 DEV/ HR TEST/ # ll total 0 drwxrwx--T 2 devadmin devadmin 6 Jun 30 14:26 DEV drwxrwx--T 2 hradmin hradmin 6 Jun 30 14:26 HR drwxr-xr-x 2 admin admin 6 Jun 30 14:26 Tools drwxrwx--T 2 testadmin testadmin 6 Jun 30 14:26 TEST 6. 配置samba 设置: # ———————– Standalone Server Options ——————- security = user passdb backend = tdbsam # ———————– Share Definitions ——————- [DEV] comment = This is a directory of Project. path = /company/DEV/ public = no admin users = devadmin valid users = @devadmin writable = yes create mask = 0777 directory mask = 0775 [TEST] comment = This is a directory of TEST. path = /company/TEST/ public = no admin users = testadmin valid users = @testadmin writable = yes create mask = 0750 directory mask = 0750 [HR] comment = This is a directory of HR. path = /company/HR/ public = no admin users = hradmin valid users = @hradmin writable = yes create mask = 0750 directory mask = 0750 [SHARE] comment = This is a share directory. path = /company/share/ public = no ;admin users = admin valid users = admin,@devadmin,@hradmin,@testadmin writable = yes create mask = 0755 directory mask = 0755 7. 关闭,启动samba服务 # systemctl stop smb //关闭smb # systemctl start smb //开启smb # systemctl status smb //查看smb状态 设置samba开机重启: # systemctl enable smb
以上是关于搭建samba服务的主要内容,如果未能解决你的问题,请参考以下文章