ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

centos7一键安装samba服务器

2021-11-09 09:35:49  阅读:88  来源: 互联网

标签:samba 一键 centos7 etc user conf smb dir


一键安装脚本 比较方便 用户名 密码 跟目录的话 自行修改脚本前几行的变量

#!/bin/bash
user="code"
pass="123456"
dir="/root/web"

yum install -y samba samba-client
mkdir -p $dir
chmod 777 $dir
useradd -d $dir -s /sbin/nologin $user

rm -f /etc/samba/smb.conf
cat >/etc/samba/smb.conf<<EOF
[global]
        workgroup = SAMBA
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw

[homes]
        comment = Home Directories
        valid users = %S, %D%w%S
        browseable = No
        read only = No
        inherit acls = Yes

[printers]
        comment = All Printers
        path = /var/tmp
        printable = Yes
        create mask = 0600
        browseable = No

[print$]
        comment = Printer Drivers
        path = /var/lib/samba/drivers
        write list = @printadmin root
        force group = @printadmin
        create mask = 0664
        directory mask = 0775

[$user]                                        
       comment = this is the info
       path= $dir
       writable = yes
       public = no
EOF

echo -e "$pass\n$pass\n"| pdbedit -a -u $user -t
chown -Rf $user:$user $dir
systemctl start smb
systemctl enable smb
systemctl restart smb
systemctl status smb

 

标签:samba,一键,centos7,etc,user,conf,smb,dir
来源: https://www.cnblogs.com/yuandaozhe/p/15527315.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有