trixbox下的samba的配置和如何从linux访问WINDOWS共享文件夹(samba-client的使用)

samba的配置可参考:

http://doc.linuxpk.com/1561.html

http://blog.chinaunix.net/u2/71107/showart_733101.html

http://blog.csdn.net/annicybc/archive/2006/08/28/1133899.aspx

添加record目录指向/car/spool/asterisk/monitor/, 用户名密码均为asterisk,需用smbpasswd -a asterisk 添加用户, 配置好smb.conf的内容:

# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options (perhaps too
# many!) most of which are not shown in this example
#
# For a step to step guide on installing, configuring and using samba,
# read the Samba-HOWTO-Collection. This may be obtained from:
# http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
#
# Many working examples of smb.conf files can be found in the
# Samba-Guide which is generated daily and can be downloaded from:
# http://www.samba.org/samba/docs/Samba-Guide.pdf
#
# Any line which starts with a ; (semi-colon) or a # (hash)
# is a comment and is ignored. In this example we will use a #
# for commentry and a ; for parts of the config file that you
# may wish to enable
#
# NOTE: Whenever you modify this file you should run the command "testparm"
# to check that you have not made any basic syntactic errors.
#
#---------------
# 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
#
# If you want to run scripts (preexec/root prexec/print command/...) please
# put them into the /var/lib/samba/scripts directory so that smbd will be
# allowed to run them.
# Make sure you COPY them and not MOVE them so that the right SELinux context
# is applied, to check all is ok use restorecon -R -v /var/lib/samba/scripts
#
#--------------
#
#======================= Global Settings =====================================

[global]

# ----------------------- Network Related Options -------------------------
#
# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
#
# server string is the equivalent of the NT Description field
#
# netbios name can be used to specify a server name not tied to the hostname
#
# Interfaces lets you configure Samba to use multiple interfaces
# If you have multiple network interfaces then you can list the ones
# you want to listen on (never omit localhost)
#
# Hosts Allow/Hosts Deny lets you restrict who can connect, and you can
# specifiy it as a per share option as well
#
workgroup = MYGROUP
server string = Samba Server Version %v

netbios name = 18.249

; interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
hosts allow = 127. 192.168.18. 192.168.

# --------------------------- Logging Options -----------------------------
#
# Log File let you specify where to put logs and how to split them up.
#
# Max Log Size let you specify the max size log files should reach

# logs split per machine
; log file = /var/log/samba/%m.log
# max 50KB per log file, then rotate
; max log size = 50

# ----------------------- Standalone Server Options ------------------------
#
# Security can be set to user, share(deprecated) or server(deprecated)
#
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.

security = user
passdb backend = tdbsam


# ----------------------- Domain Members Options ------------------------
#
# Security must be set to domain or ads
#
# Use the realm option only with security = ads
# Specifies the Active Directory realm the host is part of
#
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.
#
# Use password server option only with security = server or if you can't
# use the DNS to locate Domain Controllers
# The argument list may include:
# password server = My_PDC_Name [My_BDC_Name] [My_Next_BDC_Name]
# or to auto-locate the domain controller/s
# password server = *


; security = domain
; passdb backend = tdbsam
; realm = MY_REALM

; password server = <NT-Server-Name>

# ----------------------- Domain Controller Options ------------------------
#
# Security must be set to user for domain controllers
#
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.
#
# Domain Master specifies Samba to be the Domain Master Browser. This
# allows Samba to collate browse lists between subnets. Don't use this
# if you already have a Windows NT domain controller doing this job
#
# Domain Logons let Samba be a domain logon server for Windows workstations.
#
# Logon Scrpit let yuou specify a script to be run at login time on the client
# You need to provide it in a share called NETLOGON
#
# Logon Path let you specify where user profiles are stored (UNC path)
#
# Various scripts can be used on a domain controller or stand-alone
# machine to add or delete corresponding unix accounts
#
; security = user
; passdb backend = tdbsam

; domain master = yes
; domain logons = yes

# the login script name depends on the machine name
; logon script = %m.bat
# the login script name depends on the unix user used
; logon script = %u.bat
; logon path = //%L/Profiles/%u
# disables profiles support by specifing an empty path
; logon path =

; add user script = /usr/sbin/useradd "%u" -n -g users
; add group script = /usr/sbin/groupadd "%g"
; add machine script = /usr/sbin/useradd -n -c "Workstation (%u)" -M -d /nohome -s /bin/false "%u"
; delete user script = /usr/sbin/userdel "%u"
; delete user from group script = /usr/sbin/userdel "%u" "%g"
; delete group script = /usr/sbin/groupdel "%g"


# ----------------------- Browser Control Options ----------------------------
#
# set local master to no if you don't want Samba to become a master
# browser on your network. Otherwise the normal election rules apply
#
# OS Level determines the precedence of this server in master browser
# elections. The default value should be reasonable
#
# Preferred Master causes Samba to force a local browser election on startup
# and gives it a slightly higher chance of winning the election
; local master = no
; os level = 33
; preferred master = yes

#----------------------------- Name Resolution -------------------------------
# Windows Internet Name Serving Support Section:
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
#
# - WINS Support: Tells the NMBD component of Samba to enable it's WINS Server
#
# - WINS Server: Tells the NMBD components of Samba to be a WINS Client
#
# - WINS Proxy: Tells Samba to answer name resolution queries on
# behalf of a non WINS capable client, for this to work there must be
# at least one WINS Server on the network. The default is NO.
#
# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
# via DNS nslookups.

; wins support = yes
; wins server = w.x.y.z
; wins proxy = yes

; dns proxy = yes

# --------------------------- Printing Options -----------------------------
#
# Load Printers let you load automatically the list of printers rather
# than setting them up individually
#
# Cups Options let you pass the cups libs custom options, setting it to raw
# for example will let you use drivers on your Windows clients
#
# Printcap Name let you specify an alternative printcap file
#
# You can choose a non default printing system using the Printing option

load printers = yes
cups options = raw

; printcap name = /etc/printcap
#obtain list of printers automatically on SystemV
; printcap name = lpstat
; printing = cups

# --------------------------- Filesystem Options ---------------------------
#
# The following options can be uncommented if the filesystem supports
# Extended Attributes and they are enabled (usually by the mount option
# user_xattr). Thess options will let the admin store the DOS attributes
# in an EA and make samba not mess with the permission bits.
#
# Note: these options can also be set just per share, setting them in global
# makes them the default for all shares

; map archive = no
; map hidden = no
; map read only = no
; map system = no
; store dos attributes = yes


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

[homes]
comment = Home Directories
browseable = no
writable = yes
; valid users = %S
; valid users = MYDOMAIN/%S

[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes

# Un-comment the following and create the netlogon directory for Domain Logons
; [netlogon]
; comment = Network Logon Service
; path = /var/lib/samba/netlogon
; guest ok = yes
; writable = no
; share modes = no


# Un-comment the following to provide a specific roving profile share
# the default is to use the user's home directory
; [Profiles]
; path = /var/lib/samba/profiles
; browseable = no
; guest ok = yes


# A publicly accessible directory, but read only, except for people in
# the "staff" group
; [public]
; comment = Public Stuff
; path = /home/samba
; public = yes
; writable = yes
; printable = no
; write list = +staff

[record]
comment = asterisk voice record
path = /var/spool/asterisk/monitor
public = yes
writeable = yes


安装smbclient:
yum install samba-client

成功的命令:
1. 查看共享目录:
smbclient -L //192.168.18.249/asterisk [-W 域名] -U asterisk
输入密码即可
或者直接输入smbclient -L //192.168.18.249/asterisk [-W 域名] -U asterisk%asterisk 也行。

2.smbclient访问 登录:
smbclient -L //192.168.18.249/asterisk [-W 域名] -U asterisk
输入密码即可
或者直接输入smbclient //192.168.18.249/asterisk [-W 域名] -U asterisk%asterisk 也行


3.挂载smb
mount -o username=asterisk,password=asterisk //192.168.18.249/asterisk /mnt/samba


参考内容:
smbclient(samba client)

功能说明:可存取SMB/CIFS服务器的用户端程序。

语  法:smbclient [网络资源][密码][-EhLN][-B<IP地址>][-d<排错层级>][-i<范围>][-I<IP地址>][-l<记录文件>][-M<NetBIOS名称>][-n<NetBIOS名称>][-O<连接槽选项>][-p<TCP连接端口>][-R<名称解析顺序>][-s<目录>][-t<服务器字码>][-T<tar选项>][-U<用户名称>][-W<工作群组>]

补充说明:SMB与CIFS为服务器通信协议,常用于Windows95/98/NT等系统。smbclient可让Linux系统存取Windows系统所分享的资源。

参  数:
[网络资源] [网络资源]的格式为//服务器名称/资源分享名称。
[密码] 输入存取网络资源所需的密码。
-B<IP地址> 传送广播数据包时所用的IP地址。
-d<排错层级> 指定记录文件所记载事件的详细程度。
-E 将信息送到标准错误输出设备。
-h 显示帮助。
-i<范围> 设置NetBIOS名称范围。
-I<IP地址> 指定服务器的IP地址。
-l<记录文件> 指定记录文件的名称。
-L 显示服务器端所分享出来的所有资源。
-M<NetBIOS名称> 可利用WinPopup协议,将信息送给选项中所指定的主机。
-n<NetBIOS名称> 指定用户端所要使用的NetBIOS名称。
-N 不用询问密码。
-O<连接槽选项> 设置用户端TCP连接槽的选项。
-p<TCP连接端口> 指定服务器端TCP连接端口编号。
-R<名称解析顺序> 设置NetBIOS名称解析的顺序。
-s<目录> 指定smb.conf所在的目录。
-t<服务器字码> 设置用何种字符码来解析服务器端的文件名称。
-T<tar选项> 备份服务器端分享的全部文件,并打包成tar格式的文件。
-U<用户名称> 指定用户名称。
-W<工作群组或域名> 指定工作群组名称或域名称。

Linux 访问windows xp、2003的共享文件
作者:佚名 来源:不详 发布时间:2009-1-10 8:22:00
最近因为需要从windows 2003和windows xp中拷贝数据,而linux下的共享功能又被禁用,本想使用smbclient访问windows 2003,无奈以失败告终。最后查了一上午的英文资料,终于搞定。

  在redhat-el 5.2(redhat 9.0)访问windows xp和windows 2003:

  1、访问windows xp

  命令格式:smbclient ip地址file:///C|/share -U share

  2、访问windows 2003

  命令格式:mount -t cifs //ip地址/共享文件夹名 /本地目录 --verbose -o user=username


smbclient是在linux命令行下访问samba服务器的工具
常见用法如下:

列出服务器上共享
#smbclient -L 机器IP -U 用户名%密码
例:#smbclient -L //192.168.0.2/public -U benson%1

登入samba
#smbclient //机器IP/共享目录 -U 用户名称%密码
例:#smbclient //192.168.0.2/public -U benson%1
登入成功后出现提示符 smb:/> ,接下来的操作和ftp时命令一样,用get下载文件而用put上传文件,命令可以用help查看。

samba报错:session setup failed: NT_STATUS_LOGON_FAILURE 解决

今天公司有同事samba用不了,具体步骤如下:

[bruceg@developerjail /home]$ smbclient -L file:///C|/IPADRESS -U zhongw
Enter berbiey's password:
session setup failed: NT_STATUS_LOGON_FAILURE

网上查看相关问题,发现可能是系统或者samba中某一处用用户引起的,正确的应该是samba和系统中同时有该用户!

解决办法:

bruceg@developerjail /home]$ sudo /usr/local/bin/smbpasswd -a zhongw


[bruceg@developerjail /home]$ smbclient -L file:///C|/IPADDRESS -U zhongw

Enter zhongw's password:
Domain=[DEVELOPERJAIL] OS=[Unix] Server=[Samba 3.3.8]

Sharename Type Comment
--------- ---- -------
IPC$ IPC IPC Service (Samba Server)
zhongw Disk Home Directories
Domain=[DEVELOPERJAIL] OS=[Unix] Server=[Samba 3.3.8]

Server Comment
--------- -------

Workgroup Master
--------- -------
MYGROUP DEVELOPERJAIL

问题得到解决

NT_STATUS_LOGON_FAILURE


samba求助:session setup failed: NT_STATUS_LOGON_FAILURE


1.session setup failed: NT_STATUS_LOGON_FAILURE
该错误表示用户有误, 可能是用户不存在, 也有可能是密码错误, 或者用户只是在samba和系统的用户中的一个地方存在,
总之是用户和密码有问题
2. tree connect failed: NT_STATUS_BAD_NETWORK_NAME
这个错误则表示共享目录有误, 可能是目录不存在, 或者权限不对
我的情况是这样的. 我有一个明为xiaowang的用户, 在xiaowang的主目录下我新建了一个share目录,
并且吧share添加到smb.conf中成为一个共享目录myshare, 但是我有指定该共享目录的有效用户为guest(也是系统中的一个用户),
结果guest没有访问xiaowang主目录下的文件的权限. 现在我把share目录健在home下就好使了.
转自http://bbs.chinaunix.net/archiver/tid-309136.html


smbclient 连接出错:tree connect failed: NT_STATUS_BAD_NETWORK_NAME

从RedHat 5中用 smbclient 连接Win2K3报错:


查了半天~ 郁闷了半天~ 结果才发现,我的Win2K3公布出来的根目录名是E$,不能再指定下级目录。用下面这样就对了:
smbclient //172.18.27.55/E$ -U xx%xx

Powered by Zoundry Raven

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值