搭建Samba
程序员文章站
2024-03-14 15:43:28
...
Centos6 上搭建Samba服务器
#!/bin/sh
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
setenforce 0
yum install samba -y
service smb start
echo "admin " | useradd -s /sbin/nologin admin
echo "admin " | smbpasswd -a admin
chown admin.admin /root/share
cp /etc/samba/smb.conf /etc/samba/smb.conf_bak
>/etc/samba/smb.conf
cat >>/etc/samba/smb.conf << EOF
[global]
workgroup = SC.LOCAL
server string = Samba Server Version %v
netbios name = NetTrade-File-Server
log file = /var/log/samba/%m.log
max log size = 10240
security = user
passdb backend = tdbsam
[shared]
# 共享文件目录描述
# comment = Shared Directories
# 共享文件目录
path = /root/share/
# 是否允许guest访问
public = no
# 指定管理用户
admin users = admin
# 可访问的用户组、用户
valid users = @admin
# 是否浏览权限
browseable = yes
# 是否可写权限
writable = yes
# 文件权限设置
create mask = 0777
directory mask = 0777
force directory mode = 0777
force create mode = 0777
EOF
service smb restart
# 设置开机启动
echo "service smb restart" >> /etc/rc.local
# 防止防火墙阻止
/sbin/iptables -I INPUT -p tcp --dport 139 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 445 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/rc.d/init.d/iptables restart
Centos7上搭建Samba服务器
#!/bin/sh
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
setenforce 0
yum install samba -y
systemctl start smb
echo "admin " | useradd -s /sbin/nologin admin
echo "admin " | smbpasswd -a admin
chown admin.admin /root
cp /etc/samba/smb.conf /etc/samba/smb.conf_bak
>/etc/samba/smb.conf
cat >>/etc/samba/smb.conf << EOF
[global]
workgroup = SC.LOCAL
server string = Samba Server Version %v
netbios name = NetTrade-File-Server
log file = /var/log/samba/%m.log
max log size = 10240
security = user
passdb backend = tdbsam
[shared]
# 共享文件目录描述
# comment = Shared Directories
# 共享文件目录
path = /root/
# 是否允许guest访问
public = no
# 指定管理用户
admin users = admin
# 可访问的用户组、用户
valid users = @admin
# 是否浏览权限
browseable = yes
# 是否可写权限
writable = yes
# 文件权限设置
create mask = 0666
directory mask = 0666
force directory mode = 0666
force create mode = 0666
EOF
systemctl enable smb
Ubuntu16
#!/bin/sh
apt-get install samba samba-common -y
systemctl start smbd
systemctl start nmbd
echo "admin " | useradd -s /sbin/nologin admin
echo "admin " | smbpasswd -a admin
chown admin.admin /root
cp /etc/samba/smb.conf /etc/samba/smb.conf_bak
>/etc/samba/smb.conf
cat >>/etc/samba/smb.conf << EOF
[global]
workgroup = SC.LOCAL
server string = Samba Server Version %v
netbios name = NetTrade-File-Server
log file = /var/log/samba/%m.log
max log size = 10240
security = user
passdb backend = tdbsam
[shared]
# 共享文件目录描述
# comment = Shared Directories
# 共享文件目录
path = /root/
# 是否允许guest访问
public = no
# 指定管理用户
admin users = admin
# 可访问的用户组、用户
valid users = @admin
# 是否浏览权限
browseable = yes
# 是否可写权限
writable = yes
# 文件权限设置
create mask = 0666
directory mask = 0666
force directory mode = 0666
force create mode = 0666
EOF
systemctl enable smbd
systemctl enable nmbd
上一篇: 微信小程序aes和rsa加密解密
下一篇: 配置属性加解密之对称加密