文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>windows通过samba服务 访问linux,资源共享...

windows通过samba服务 访问linux,资源共享...

时间:2010-08-06  来源:zdl1016

---安装samba

首先在linux下安装 samba。怎么安装就不说了,我的虚拟机ubuntu1004自带有。
通过 whereis samba 可以知道是否安装了samba,如果安装了,提示:
samba: /etc/samba /usr/lib/samba /usr/share/samba /usr/share/man/man7/samba.7.gz

---配置samba

首先说明,咱是方便自己用的,不用很复杂的配置,网上说的 什么增加删除用户啥的,通过这个方式均不需要。非常的easy,修改smb.conf配置文件,重启samba服务即可。
怎么修改配置呢?
smb.conf的位置:/etc/samba/ 目录下,修改前先备份。
修改方法:按照smb.conf文件本身的提示修改即可。

这里列举如下:
# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = WORKGROUP // 查看你的windows的组,确保两个一样,一般情况下都一样。

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

# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares.  This will share each
# user's home directory as \\server\username

# eg \\虚拟机ip\nemo; \\虚拟机ip\root

# 使得每个用户 输入\\虚拟机ip\nemo 进去的目录是 对应的用户的工作目录 \home\root
[homes]
   comment = Home Directories
   browseable = no                  // no将在windows的资源管理器树形结构里面看不到目录

# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
   read only = no                       // 使具有写的权限

# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
   create mask = 0755

# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
   directory mask = 0755


# By default, \\server\username shares can be connected to by anyone
# with access to the samba server.  Un-comment the following parameter
# to make sure that only "username" can connect to \\server\username
# This might need tweaking when using external authentication schemes
;   valid users = %S

ok,到此为止,保存退出。默认该文件是只读的,需要root权限。


---启动 samba

配置文件修改好了,可以重启samba了。

有人 建议 通过 /etc/init.d/smbd restart 重启,但是 貌似不行,还是按照下面的方式重启比较好。

查看samba服务 是否在运行
sudo ps aux|grep smb
如果显示:
root      2012  0.0  0.7  15280  3980 ?        Ss   11:27   0:00 smbd -F
说明正在运行。

停止 samba服务
sudo service smbd stop
提示:smbd stop/waiting
此时再查看进程,发现smbd已不在


启动 samba服务
sudo service smbd start
提示:smbd start/running, process 2064

如果 samba服务在运行,直接重启
sudo service smbd restart

--- 在windows中访问 linux 映射网络驱动器。

如果在网上邻居里面查看,看不到linux主机,不知为什么。
并且映射网络驱动器时,如果直接输入 \\linux-ip 也提示查找失败。点击“浏览”按钮也不行,比如直接输入子目录才行。比如直接映射到\\linux-ip\username;
在ie地址栏里,输入 \\linux-ip\username 也可以登陆。提示输入linux的用户名和密码即可。
eg 输入 \\linux-ip\nemo, 用户名:root,密码****,即可访问到 /home/nemo;

注意:映射网络驱动器是,一定要通过linux主机的ip,不要通过dns解析的域名,比如\\localhost2\nemo,这样会访问失败的!


----------------------------------------------------------------------------------------------------------------------
2010.8.7号续
今日当我重新开机后发现,连接不到服务器了,只能通过账号root ,密码1****连上。
而且在nemo目录下建的文件都是 拥有者为root。但是我的securecRT连接账户是nemo,这导致编辑文件带来了麻烦。

通过如下方式修正。

1:往配置项里面加上如下几项如下

 [nemo-config] 
        comment = nemo-config // 改名字将是在windows资源管理器里看到的文件夹名字
        path = /home/nemo       // 登陆上面对应名字文件夹对应的linux下主目录
        valid users = nemo         // 允许那个账户访问该nemo-config文件夹
        read only = No
        create mask = 0777

2:添加完后利用执行testparm命令,检查smb.conf是否有语法错误。
   testparm

注意,smb的账户和linux的账户是独立的。默认smb好像是有root账户的。如果想添加nemo账户须通过 smbpasswd新增账户。

为smb新增nemo账户
sudo smbpasswd -a nemo
临时禁用 nemo账户
sudo smbpasswd -d nemo
启用nemo账户
sudo smbpasswd -e nemo

3:重新启动smbd 
   sudo service smbd restart


4:windows浏览器中输入 \\linux-ip, 将看到 nemo-config文件夹。
   进入 文件夹,提示输入账户,密码,输入 nemo,及其密码即可。(密码是通过smbpasswd新增nemo账户时设定的密码,而不是nemo的linux密码,如果nemo的smb密码忘了,通过smbpasswd删除nemo账户,并重新新增nemo账户即可重新设定密码)

----------------------------------------------------------------------------------------------------------------------

---另外一个可供参考的真实案例。
----------------------------------------------------------------------------------------------------------------------
在开发机上,smb都是已经配好的。也是不用添加账户即可访问。

访问方式:在windows下 直接\\linux-ip地址 即可访问了。

如果增加一个smb的账户nemo(nemo必须首先是linux的用户)。那么\\linux-ip的根目录里出现nemo的账户。
增加nemo账户的方法:
smbpasswd -a nemo
输入密码。

查看 smb.conf文件有如下信息
[global]
        workgroup = *****(隐去)
        printing = cups
        printcap name = cups
        printcap cache time = 750
        cups options = raw
        map to guest = Bad User
        include = /etc/samba/dhcp.conf
        logon path = \\%L\profiles\.msprofile
        logon home = \\%L\%U\.9xprofile
        logon drive = P:
[homes]
        comment = Home Directories
        valid users = %S, %D%w%S
        browseable = No
        read only = No
        inherit acls = Yes
[profiles]
        comment = Network Profiles Service
        path = %H
        read only = No
        store dos attributes = Yes
        create mask = 0600
        directory mask = 0700
[users]
        comment = All users
        path = /home
        read only = No
        inherit acls = Yes
        veto files = /aquota.user/groups/shares/
[groups]
        comment = All groups
        path = /home/groups
        read only = No
        inherit acls = 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 = @ntadmin root
        force group = ntadmin
        create mask = 0664
        directory mask = 0775


更多的关于配置samba的,但不一定有用的信息参考:
http://www.360doc.com/content/06/0905/23/7469_200118.shtml

相关阅读 更多 +
排行榜 更多 +
边境警察巡逻模拟中文版下载

边境警察巡逻模拟中文版下载

角色扮演 下载
数码宝贝世界复原手机版下载

数码宝贝世界复原手机版下载

角色扮演 下载
土地抢夺者中文手机版下载

土地抢夺者中文手机版下载

策略塔防 下载