阿里云服务器的Samba配置
阿里云服务器的Samba配置
阿里云服务器ECS的samba配置方法
昨天在阿里云上买了半年的阿里云服务器,需要配置samba服务,以方便文件复制,按照网上的很多帖子配置samba服务,整了好久才成功,现在记下配置过程,希望对于有需要的同学能够有所帮助。
1. 安装iptables防火墙
安装iptables和iptables-services
yum install iptables
yum install iptables-services
*关闭centos自带的防火墙
systemctl stop firewalld
systemctl mask firewalld
2. 清空防火墙默认规则和自定义规则
iptables -P INPUT ACCEPT
iptables -F
iptables -X
iptables -Z
3. 防火墙开放samba服务所需端口和常用端口
vi /etc/sysconfig/iptables
添加以下内容到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
-A INPUT -p tcp –dport 22 -j ACCEPT
-A INPUT -p tcp –dport 21 -j ACCEPT
-A INPUT -p tcp –dport 80 -j ACCEPT
-A INPUT -p tcp –dport 443 -j ACCEPT
-A INPUT -p icmp –icmp-type 8 -j ACCEPT
-A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT
-P OUTPUT ACCEPT
4. 开启iptables防火墙
注册iptables服务
systemctl enable iptables.service
开启服务
systemctl start iptables.service
查看状态
systemctl status iptables.service
5. 安装和配置samba
yum install samba
设置samba开机启动
chkconfig smb on
vim /etc/samba/smb.conf,粘贴复制以下内容
[global]
unix charset = gbk
dos charset = gbk
workgroup = img
netbios name = img
server string = uc
security = user
smb ports = 1315 1314 #很重要,貌似阿里云屏蔽了samba默认的端口
[img]
comment = uc
path=/home/xuhaoguang/work
create mask = 0664
directory mask = 0775
writable = yes
valid users = work #登录samba服务的账号
browseable = yes
给samba添加work账号:
smbpasswd -a work
启动samba:
service smb restart
6. 客户端连接samba服务
mac:
command +k ; smb://ip_address:1314
windows:
运行输入:\Samba服务器的ip
————————————————
版权声明:本文为CSDN博主「XHG1993」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/XHG1993/article/details/78872724