Setup SAMBA on CentOS7

Setup Group and User

add user (will add the same group at the same time)

sudo useradd -m jenkins

set password

sudo passwd jenkins

grant `sudo` permission to new user

sudo usermod -aG wheel jenkins

check new user has `wheel` group 

vi /etc/group

wheel:x:10:jenkins

switch user

su - jenkins

Setup SAMBA Server

Ensure disable SELinux if you linux is located in Intra-net

Install SAMBA

sudo yum install samba

Enable SAMBA

sudo systemctl start smb nmb
sudo systemctl enable smb nmb

Configure Firewalld to allow access

firewall-cmd –-permanent –-add-service=samba
firewall-cmd –-reload

backup SAMBA conf file first

cp smb.conf smb.conf.bak

Modify SAMBA conf file

sudo vi /etc/samba/smb.conf
[global]
        workgroup = JENKINSGROUP
        netbios name = team-env
        security = user
        encrypt passwords = yes
[sharefolder]
        browseable = yes
        comment = Shared Folder
        path = /home/jenkins/sharefolder
        read only = No
        create mask = 665
        force create mode = 665
        directory mask = 0775
        force directory mode = 0775
        valid users = jenkins

restart SAMBA service after modification conf

sudo systemctl restart smb nmb

2770 to the shared folder

sudo chmod 2770 /home/jenkins/sharefolder

before

drwxrwxr-x 2 jenkins jenkins 6 Apr  5 06:59 sharefolder

after

drwxrws--- 2 jenkins jenkins 6 Apr  5 06:59 sharefolder

Add SAMBA user

sudo smbpasswd -a jenkins

Enable SAMBA user

sudo smbpasswd -e jenkins

Setup SAMBA Client

test connection

smbclient //192.168.22.33/sharefolder

to mount 

sudo mount -t cifs -o uid=jenkins,gid=jenkins,username=jenkins //192.168.22.33/sharefolder /home/jenkins/sharefolder

to unmout

sudo umount /home/jenkins/sharefolder 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值