应用场景
有一台windows工作站,连的有检测设备,检测设备会每隔一分钟往一个文件里追加一条检测结果,现在想用flume来监控这个文件,flume是运行在一台Linux服务器上,所以需要把windows上的目录映射到Linux上。
我的测试环境
windows 10
Linux centos7.4
windows上创建一个目录
1、在E盘下创建一个shareLinux的文件夹
2、在文件夹上右键、属性、共享,打开配置窗口
选择一个用户,修改其权限级别,最后点击共享。
开启windows的smb服务器
控制面版、程序和功能、启用或关闭windows功能,把SMB 1.0/CIFS服务器一栏勾选上,然后确定。
在Linux上操作
先安装了cifs-utils工具
yum install cifs-utils
创建一个目录,用来挂载windows上的共享文件夹
mkdir /media/windowshare
mount -t cifs //192.168.3.125/shareLinux /media/windowshare/ -o username="abc",password="123",iocharset=utf8,sec=ntlmssp
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs
查看错误信息,可以进入/var/log
目录下,使用dmesg | tail
指令查看。
上述提示密码访问被拒绝,搜了很多资料,大概有以下几种方案
1、说用户名和密码加双引号,经验证,在我的环境下无效。
2、说更改组策略,经验证,在我的环境无效。
在运行中输入gpedit.msc
,打开组策略管理器,在网络访问中修改本地账户的共享和安全模型,修改为经典的。
(window10家庭版没有这个东西,可以参考这篇博客)
安装组策略:https://blog.csdn.net/zz_aiytag/article/details/108444884
3、在命令中增加sec参数,我挨个试了,经验证无效
sec=
Security mode. Allowed values are:¡¤ none - attempt to connection as a null user (no name) ¡¤ krb5 - Use Kerberos version 5 authentication ¡¤ krb5i - Use Kerberos authentication and forcibly enable packet signing ¡¤ ntlm - Use NTLM password hashing ¡¤ ntlmi - Use NTLM password hashing and force packet signing ¡¤ ntlmv2 - Use NTLMv2 password hashing ¡¤ ntlmv2i - Use NTLMv2 password hashing and force packet signing ¡¤ ntlmssp - Use NTLMv2 password hashing encapsulated in Raw NTLMSSP message ¡¤ ntlmsspi - Use NTLMv2 password hashing encapsulated in Raw NTLMSSP message, and force packet signing The default in mainline kernel versions prior to v3.8 was sec=ntlm. In v3.8, the default was changed to sec=ntlmssp. If the server requires signing during protocol negotiation, then it may be enabled automatically. Packet signing may also be enabled automatically if it's enabled in /proc/fs/cifs/SecurityFlags.
转变思路,换另台windows验证
找另一台windows电脑,添加一个网络位置
进入下一步之后,输入正确的用户名和密码,发会现,仍然提示指定的网络密码不正确。
关闭密码验证
在共享文件夹的共享里,找到网络和共享中心,可以点进去
也可以从所有设置、网络和共享中心那里进入
进入更改高级共享设置,将密码保护的共享改为无密码保护,确定。
Linux上再次挂载
再次验证,可成功挂载
这时这个指令里的用户名和密码都是任意的就行。
[root@ftpserver media]# mount -t cifs //192.168.3.125/shareLinux /media/windowshare/ -o username="abc",password="123",iocharset=utf8,sec=ntlmssp
[root@ftpserver media]# ll /media/windowshare/
total 0
-rwxr-xr-x 1 root root 0 Sep 7 10:54 1.txt
取消挂载
[root@ftpserver media]# umount -f windowshare/