阿里云服务器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. 安装和配置sambayum install samba
设置samba开机启动
chkconfig smb onvim /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:1314windows:
运行输入:\Samba服务器的ip
我是按照上面的步骤完成阿里云服务器上的samba配置的,仅供大家参考!