本文共 3417 字,大约阅读时间需要 11 分钟。
由于工作需要,需要使用samba在windows下访问linux下的文件,主要是编译环境,linux下使用的是root用户,SSH登陆,而开发是在windows下,代码在windows下开发,为了开发的文件能方便共享,提高开发效率,就折腾了一下samba。
安装samba:yum install samba
开机启动:chkconfig smb on
chkconfig smb on
samba添加root用户访问:useradd root(默认已有)
smbpasswd -a root ---后面输入密码
配置samba:(主要配置)
[global] workgroup = SAMBA security = user passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw[test] comment = Home Directories path=/home/test valid users = test,root writable = yes directory mask = 0775 create mask = 0775 valid users = test,root write list = test,root browseable = yes available = yes[printers] comment = All Printers path = /var/tmp printable = Yes create mask = 0600 browseable = No[print$] comment = Printer Drivers path = /var/lib/samba/drivers write list = @printadmin root force group = @printadmin create mask = 0664 directory mask = 0775
重启samba
service smb restart
windows下清除共享用户名和密码:net use * /delete
windows下访问共享:\\xx.xx.xx.xx\xx
linux下挂载使用命令:
mount.cifs -o username="test",password="test",sec=ntlmssp //172.28.107.2/test /opt/rh/
期间使用mount.cifs -o username="test",password="test" //172.28.107.2/home/test /opt/rh/有遇到如下问题:
mount.cifs -o domain="SAMBA",username="test",password="test",sec=ntlm //172.28.107.6/home/test /opt/ -vmount.cifs kernel mount options: ip=172.28.107.6,unc=\\172.28.107.6\home,sec=ntlm,ver=1,user=test,domain=SAMBA,prefixpath=test,pass=********mount error(13): Permission deniedRefer to the mount.cifs(8) manual page (e.g. man mount.cifs)[root@localhost home]# dmesgStatus code returned 0xc000006d NT_STATUS_LOGON_FAILURECIFS VFS: Send error in SessSetup = -13CIFS VFS: cifs_mount failed w/return code = -13
该问题主要是sec值不对导致,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.
修改mount.cifs -o username="test",password="test",sec=ntlmssp //172.28.107.2/home/test /opt/rh/后又出现如下问题:
[root@localhost home]# mount.cifs -o domain="SAMBA",username="test",password="test",sec=ntlmssp //172.28.107.6/home/test /opt/ -vmount.cifs kernel mount options: ip=172.28.107.6,unc=\\172.28.107.6\home,sec=ntlmssp,ver=1,user=test,domain=SAMBA,prefixpath=test,pass=********Retrying with upper case share namemount.cifs kernel mount options: ip=172.28.107.6,unc=\\172.28.107.6\HOME,sec=ntlmssp,ver=1,user=test,domain=SAMBA,prefixpath=TEST,pass=********mount error(6): No such device or addressRefer to the mount.cifs(8) manual page (e.g. man mount.cifs)[root@localhost home]# dmesgStatus code returned 0xc000006d NT_STATUS_LOGON_FAILURECIFS VFS: cifs_mount failed w/return code = -6
该问题主要是没有目录,该目非具体路径,而是samba配置的[test],修改为test后就可以了
转载地址:http://vqdob.baihongyu.com/