linux samba win7访问,win7如何通过samba访问linux

配置完毕后重启网络,输入命令 service network restart ,

接着检验windows PC 和 linux 能不能连通,linux下执行ping

192.168.154.1 windows PC下执行 ping 192.168.154.128

,两者要互通才行。

4、linux下配置samba

输入命令: vi

/etc/samba/smb.conf

按Pagedown

查找share Definitions,修改如下

#========================= Share Definitions

==========================

[root]

Comment = Root Directories

Browseable = yes

Writable =yes

Path =

/ (共享的目录,设置为根目录)

Valid users = *** (windows 下访问

linux 需要的账户名)

配置完毕,保存。

5、启动samba

输入命令 /etc/init.d/smb restart

6、添加samba用户

前提是此用户为linux的用户,所以要先添加一个linux用户

如: groupadd test

-----添加一个用户组

Useradd abc –g test –d

/home/test/ -----添加一个名为abc

的用户,并加入test组,用户目录为/home/test/

Smbpasswd –a

abc -----添加一个名为abc的samba用户,修改密码

7、从win7通过samba访问linux

在XP下,可以通过\\192.168.154.128(Linux系统IP)进行访问其共享文件,但在WIN7或VISTA下却不行,因为Samba只支持NTLM认证,而WIN7或VISTA则采用NTLMv2认证,因此必须经过一些设置才行,具体设置如下:

单击[开始]——[运行] 输入 “secpol.msc”打开管理工具,展开“本地策略”;

然后,单击“安全选项”。 双击“网络安全:LAN Manager 身份验证级别”;

最后,单击列表中:发送LM和NTLMv2,如果已协商,则使用NTLMv2协议。

设置好了之后,就可以运行\\X.X.X.X (linux的IP)。

8、访问/修改linux共享文件

通过以上设置win7已经能访问linux共享文件了,可是要在共享目录下新建文件或者对已有文件进行修改是不行的,系统总提醒“没有权限”。

于是乎,修改共享文件的权限,如笔者的共享目录是“/temp”,所以执行

Chmod 757 /temp/ -----也即将“其他用户”的权限修改为可读、可写、可执行。

重新运行\\X.X.X.X linux

ip ,发现还是不行。

后来查看了samba的配置文件,发现这么一些东西

#---------------

# SELINUX NOTES:

#

# If you want to use the useradd/groupadd family of

binaries please run:

# setsebool -P samba_domain_controller on

#

# If you want to share home directories via samba

please run:

# setsebool -P samba_enable_home_dirs on

#

# If you create a new

directory you want to share you should mark it as

# "samba-share_t" so that

selinux will let you write into it.

# Make sure not to do that on

system directories as they may already have

# been marked with othe

SELinux labels.

#

# Use ls -ldZ /path to see

which context a directory has

#

# Set labels only on

directories you created!

# To set a label use the

following: chcon -t samba_share_t /path

#

# If you need to share a system created directory

you can use one of the

# following (read-only/read-write):

# setsebool -P samba_export_all_ro on

# or

# setsebool -P samba_export_all_rw on

意思即是如果要让你自己建的文件能被共享且允许被写,需要set a label “samba_share_t” to it

.所以运行 chcon –t samba_share_t /temp/

输入命令 ls –ldZ /temp/ ,得到:

drwxr-xrwx root root

root:object_r:samba_share_t /temp/

说明修改成功了。

再一次访问linux的共享文件,这次不仅能修改原来的文件,而且能新建文件了。

a4c26d1e5885305701be709a3d33442f.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值