标签:table 系统版本 work put raw stat smb mamicode int
公司客户机Linux服务器上需要共享目录提供给客户上传下载文件(特别要求是傻瓜式的),Windows共享我倒是用过,Linux的话,之前没接触过这个业务,所以特此编写本篇文章以备不时之需。
服务器:1台
系统版本:CentOS Linux release 7.7.1908 (Core)
# samba提供共享服务,client是客户端用于测试 [root@k8s-master smds]# yum -y install samba samba-client # 查看Selinux状态 [root@k8s-master smds]# sestatus SELinux status: disabled # 关闭防火墙或开通以下端口 <port protocol="tcp" port="139"/> <port protocol="tcp" port="389"/> <port protocol="tcp" port="445"/> <port protocol="tcp" port="901"/> <port protocol="udp" port="137"/> <port protocol="udp" port="138"/>
# 备份默认配置文件 cp /etc/samba/smb.conf /etc/samba/smb.conf.bak # 修改配置文件(ntlm auth = yes开启后,变成了匿名访问,暂不深究) cat >/etc/samba/smb.conf<<EOF [global] workgroup = WORKGROUP server string = Samba Server Version %v security = user passdb backend = tdbsam load printers = yes cups options = raw ntlm auth = yes [share] comment = share for users path = /var/oa_public/saveFiles browseable = yes writable = yes public = no EOF
mkdir -p /var/oa_public/saveFiles chmod -R 777 /var/oa_public/saveFiles
[root@k8s-node2 ~]# smbclient //192.168.12.222/share/ -U sambauser Enter WORKGROUP\sambauser‘s password: Try "help" to get a list of possible commands. smb: \> ls . D 0 Fri May 8 12:45:30 2020 .. D 0 Fri May 8 11:04:22 2020 38680576 blocks of size 1024. 1329076 blocks available smb: \> lcd /etc/ smb: \> put passwd putting file passwd as \passwd (155.0 kb/s) (average 155.0 kb/s) smb: \> ls . D 0 Fri May 8 12:59:15 2020 .. D 0 Fri May 8 11:04:22 2020 passwd A 1111 Fri May 8 12:59:15 2020 38680576 blocks of size 1024. 1329072 blocks available
至此,可以随意上传下载文件了
smb用户是基于Linux系统用户的,所以得先创建Linux系统用户
useradd test
# 创建smb用户
[root@k8s-master smds]# smbpasswd -a test
New SMB password:
Retype new SMB password:
Added user test.
smbpasswd -参数
-a 添加用户 #smbpasswd -a test
-x 删除用户 #smbpasswd -x test
-d 禁用帐号 #smbpasswd -d test
-e 取消禁用 #smbpasswd -e test
-n 清除密码 #smbpasswd -a test
标签:table 系统版本 work put raw stat smb mamicode int
原文地址:https://www.cnblogs.com/cpw6/p/12849515.html