當前位置:首頁 » 雲伺服器 » 搭建samba伺服器

搭建samba伺服器

發布時間: 2022-02-04 12:31:50

1. 求linux samba 伺服器搭建

我自己的文檔

rpm -ivh samba-3.0.33-3.39.el5_8.i386.rpm --nodeps
rpm -ivh samba-client-3.0.33-3.39.el5_8.i386.rpm --nodeps
rpm -ivh samba-common-3.0.33-3.39.el5_8.i386.rpm --nodeps

rpm -qa | grep samba
samba-3.0.33-3.39.el5_8
samba-client-3.0.33-3.39.el5_8
samba-common-3.0.33-3.39.el5_8

cd /etc/samba/

mv smb.conf smb.confbak
touch sbm.conf
vi smb.conf

workgroup = LinuxSir

netbios name = LinuxSir05
server string = Linux Samba Server TestServer
security = share

[linuxsir]
path = /opt/linuxsir
writeable = yes
browseable = yes

guest ok = yes

mkdir -p /opt/linuxsir
id nobody
chown -R nobody:nobody /opt/linuxsir
[root@localhost samba]# smbd
[root@localhost samba]# nmbd
done

5.2 在伺服器上創建相應的目錄;

[root@localhost ~]# mkdir -p /opt/linuxsir
[root@localhost ~]# cd /opt/linuxsir
[root@localhost linuxsir]# mkdir sir01 sir02 sir03 sir04 sirshare sir0104rw sirallrw
[root@localhost linuxsir]# ls
sir01 sir0104rw sir02 sir03 sir04 sirallrw sirshare

5.3.1 添加用戶組;

[root@localhost ~]# /usr/sbin/groupadd linuxsir
[root@localhost ~]# /usr/sbin/groupadd sir01
[root@localhost ~]# /usr/sbin/groupadd sir02
[root@localhost ~]# /usr/sbin/groupadd sir03
[root@localhost ~]# /usr/sbin/groupadd sir04
[root@localhost ~]# /usr/sbin/groupadd sir0104

5.3.2 添加用戶;

[root@cuc03 ~]# adser -g sir01 -G sir0104 -d /opt/linuxsir/sir01 -s /sbin/nologin sir01
[root@cuc03 ~]# adser -g sir02 -G sir0104 -d /opt/linuxsir/sir02 -s /sbin/nologin sir02
[root@cuc03 ~]# adser -g sir03 -G sir0104 -d /opt/linuxsir/sir03 -s /sbin/nologin sir03
[root@cuc03 ~]# adser -g sir04 -G sir0104 -d /opt/linuxsir/sir04 -s /sbin/nologin sir04
[root@cuc03 ~]# adser -g linuxsir -d /opt/linuxsir -G
linuxsir,sir01,sir02,sir03,sir04,sir0104 -d /opt/linuxsir -s
/sbin/nologin linuxsir

[root@localhost ~]# id linuxsir
[root@localhost ~]# finger linuxsir

[root@localhost sir01]# smbpasswd -a linuxsir
New SMB password: 註:在這里添加Samba用戶linuxsir的密碼;
Retype new SMB password: 註:再輸入一次;
用同樣的方法來添加 sir01、sir02、sir03、sir04的密碼;

[root@cuc03 ~]# chmod 755 /opt/linux
[root@cuc03 ~]# chown linuxsir:linuxsir /opt/linuxsir
[root@cuc03 ~]# cd /opt/linuxsir
[root@cuc03 ~]# chmod 2770 sir0*
[root@cuc03 ~]# chown sir01.linuxsir sir01
[root@cuc03 ~]# chown sir02.linuxsir sir02
[root@cuc03 ~]# chown sir03.linuxsir sir03
[root@cuc03 ~]# chown sir04.linuxsir sir04
[root@cuc03 ~]# chown linuxsir.sir0104 sir0104rw
[root@cuc03 ~]# chown linuxsir.linuxsir sirshare
[root@cuc03 ~]# chmod 755 sirshare
[root@cuc03 ~]# chown linuxsir:linuxsir sirallrw
[root@cuc03 ~]# chmod 3777 sirallrw

5.4 修改Samba配置文件 smb.conf;

配置文件如下,修改/etc/samba/smb.conf後,不要忘記重啟smbd和nmbd伺服器;
[global]
workgroup = LINUXSIR
netbios name = LinuxSir
server string = Linux Samba TestServer
security = share
[linuxsir]
comment = linuxsiradmin
path = /opt/linuxsir/
create mask = 775
#create mask是用戶創建文件時的許可權掩碼;
directory mask = 0775
#directory mask 是用來設置用戶創建目錄時的許可權掩碼,意思是對於用戶和用戶組可讀可寫,對其它用戶可讀可執行;
writeable = yes
valid users = linuxsir
browseable = yes
[sirshare]
path = /opt/linuxsir/sirshare
writeable = yes
browseable = yes
guest ok = yes
[sirallrw]
path = /opt/linuxsir/sirallrw
writeable = yes
browseable = yes
guest ok = yes
[sir0104rw]
comment = sir0104rw
path = /opt/linuxsir/sir0104rw
create mask = 775
directory mask = 0775
writeable = yes
valid users = linuxsir,@sir0104
#@sir0104是用戶組;
browseable = yes
[sir01]
comment = sir01
path = /opt/linuxsir/sir01
create mask = 775
directory mask = 0775
writeable = yes
valid users = sir01,@linuxsir
browseable = yes
[sir02]
comment = sir02
path = /opt/linuxsir/sir02
create mask = 775
directory mask = 0775
writeable = yes
valid users = sir02,@linuxsir
browseable = yes
[sir03]
comment = sir03
path = /opt/linuxsir/sir03
create mask = 775
directory mask = 0775
writeable = yes
valid users = sir03,@linuxsir
browseable = yes
[sir04]
comment = sir04
path = /opt/linuxsir/sir04
create mask = 775
directory mask = 0775
writeable = yes
valid users = sir04,@linuxsir
browseable = yes

2. 新手學習linux搭建samba伺服器,無法訪問

1、首先相互能PING通
2、關掉防火牆
3、配置samba
第一步:修改配置文件,把下面段寫入smb.conf的最後
[global]
workgroup
=
LinuxSir
netbios
name
=
LinuxSir05
server
string
=
Linux
Samba
Server
TestServer
security
=
share
[linuxsir]
path
=
/opt/linuxsir
writeable
=
yes
browseable
=
yes
guest
ok
=
yes
第二步:建立相應目錄並授權;
[root@localhost
~]#
mkdir
-p
/opt/linuxsir
[root@localhost
~]#
id
nobody
uid=99(nobody)
gid=99(nobody)
groups=99(nobody)
[root@localhost
~]#
chown
-R
nobody:nobody
/opt/linuxsir
注釋:
關於授權nobody,我們先用id命令查看了nobody用戶的信息,發現他的用戶組也是nobody,我們要以這個為准。有些系統nobody用戶組並非是nobody

第三步:啟動smbd和nmbd伺服器;
[root@localhost
~]#
smbd
[root@localhost
~]#
nmbd

3. Linux如何搭建samba服務

主配置文件:

/etc/samba/smb.conf

#=================== Global Settings===============

[global]部分設置,主要就是下列幾項,其餘可以保持不變,當然你要比較復雜高級的功能服務的話,那就另當別論了;

# workgroup = NT-Domain-Name or Workgroup-Name

workgroup = MSHOME #主機所屬工作組名稱

# server string is the equivalent of the NT Description field

server string = Samba Server #SAMBA伺服器主機的注釋,可選,但是建議還是留著,而且盡量寫的詳細准確,有助於識別;

# Security mode. Most people will want user level security. See security_level.txt for details.

security = share #安全模式,由於是共享目錄,所以用share;

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

共享部分設置其它保存不動,直接在最後面添加你要共享的目錄即可,同時要注意其訪問許可權;

[nfs]

path = /var/nfs

public = yes

writable = yes

/var/nfs目錄對所有用戶都可讀可寫;

四、啟動服務

通過以上簡單的設置,重啟服務後,即可在Windows下在網上鄰居中進行訪問;

在FC5下,服務名為smb及nmb,啟動smb時自動將nmb也啟動;

五、注意事項

1、防火牆問題

2、確保共享目錄的訪問許可權

3、通過網上鄰居訪問相應共享目錄前,必須確保目錄在伺服器上存在。

範本:vi /etc/samba/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

#

# 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.

#

#======================= Global Settings =====================================

[global]

# workgroup = NT-Domain-Name or Workgroup-Name

workgroup = WORKGROUP

netbios name = rayman_linux

# server string is the equivalent of the NT Description field

server string =Linux Samba Server TestServer

# This option is important for security. It allows you to restrict

# connections to machines which are on your local network. The

# following example restricts access to two C class networks and

# the "loopback" interface. For more examples of the syntax see

# the smb.conf man page

; hosts allow = 192.168.1. 192.168.2. 127.

# if you want to automatically load your printer list rather

# than setting them up indivially then you'll need this

printcap name = /etc/printcap

load printers = yes

# It should not be necessary to spell out the print system type unless

# yours is non-standard. Currently supported print systems include:

# bsd, sysv, plp, lprng, aix, hpux, qnx, cups

printing = cups

# Uncomment this if you want a guest account, you must add this to /etc/passwd

# otherwise the user "nobody" is used

guest account = detack

# this tells Samba to use a separate log file for each machine

# that connects

log file = /var/log/samba/%m.log

# Put a capping on the size of the log files (in Kb).

max log size = 0

# Security mode. Most people will want user level security. See

# security_level.txt for details.

security = share

# Use password server option only with security = server

# 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 = *

; password server = <NT-Server-Name>

# Password Level allows matching of _n_ characters of the password for

# all combinations of upper and lower case.

; password level = 8

; username level = 8

# You may wish to use password encryption. Please read

# ENCRYPTION.txt, Win95.txt and WinNT.txt in the Samba documentation.

# Do not enable this option unless you have read those documents

encrypt passwords = yes

smb passwd file = /etc/samba/smbpasswd

# The following is needed to keep smbclient from spouting spurious errors

# when Samba is built with support for SSL.

; ssl CA certFile = /usr/share/ssl/certs/ca-bundle.crt

# The following are needed to allow password changing from Windows to

# update the Linux system password also.

# NOTE: Use these with 'encrypt passwords' and 'smb passwd file' above.

# NOTE2: You do NOT need these to allow workstations to change only

# the encrypted SMB passwords. They allow the Unix password

# to be kept in sync with the SMB password.

unix password sync = Yes

passwd program = /usr/bin/passwd %u

passwd chat = *New*password* %n\n *Retype*new*password* %n\n *passwd:*all*authentication*tokens*updated*successfully*

# You can use PAM's password change control flag for Samba. If

# enabled, then PAM will be used for password changes when requested

# by an SMB client instead of the program listed in passwd program.

# It should be possible to enable this without changing your passwd

# chat parameter for most setups.

pam password change = yes

# Unix users can map to different SMB User names

; username map = /etc/samba/smbusers

# Using the following line enables you to customise your configuration

# on a per machine basis. The %m gets replaced with the netbios name

# of the machine that is connecting

; include = /etc/samba/smb.conf.%m

# This parameter will control whether or not Samba should obey PAM's

# account and session management directives. The default behavior is

# to use PAM for clear text authentication only and to ignore any

# account or session management. Note that Samba always ignores PAM

# for authentication in the case of encrypt passwords = yes

obey pam restrictions = yes

# Most people will find that this option gives better performance.

# See speed.txt and the manual pages for details

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

# Configure Samba to use multiple interfaces

# If you have multiple network interfaces then you must list them

# here. See the man page for details.

; interfaces = 192.168.12.2/24 192.168.13.2/24

# Configure remote browse list synchronisation here

# request announcement to, or browse list sync from:

# a specific host or from / to a whole subnet (see below)

; remote browse sync = 192.168.3.25 192.168.5.255

# Cause this host to announce itself to local subnets here

; remote announce = 192.168.1.255 192.168.2.44

# 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

; local master = no

# OS Level determines the precedence of this server in master browser

# elections. The default value should be reasonable

; os level = 33

# 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 master = yes

# Preferred Master causes Samba to force a local browser election on startup

# and gives it a slightly higher chance of winning the election

; preferred master = yes

# Enable this if you want Samba to be a domain logon server for

# Windows95 workstations.

; domain logons = yes

# if you enable domain logons then you may want a per-machine or

# per user logon script

# run a specific logon batch file per workstation (machine)

; logon script = %m.bat

# run a specific logon batch file per username

; logon script = %U.bat

# Where to store roving profiles (only for Win95 and WinNT)

# %L substitutes for this servers netbios name, %U is username

# You must uncomment the [Profiles] share below

; logon path = \\%L\Profiles\%U

# Windows Internet Name Serving Support Section:

# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server

; wins support = yes

# WINS Server - Tells the NMBD components of Samba to be a WINS Client

# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both

; wins server = w.x.y.z

# 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.

; wins proxy = yes

# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names

# via DNS nslookups. The built-in default for versions 1.9.17 is yes,

# this has been changed in version 1.9.18 to no.

dns proxy = no

# Case Preservation can be handy - system default is _no_

# NOTE: These can be set on a per share basis

; preserve case = no

; short preserve case = no

# Default case is normally upper case for all DOS files

; default case = lower

# Be very careful with case sensitivity - it can break things!

; case sensitive = no

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

[homes]

comment = Home Directories

browseable = no

writable = yes

valid users = %S

create mode = 0664

directory mode = 0775

# If you want users samba doesn't recognize to be mapped to a guest user

; map to guest = bad user

# Un-comment the following and create the netlogon directory for Domain Logons

; [netlogon]

; comment = Network Logon Service

; path = /usr/local/samba/lib/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 = /usr/local/samba/profiles

; browseable = no

; guest ok = yes

# NOTE: If you have a BSD-style print system there is no need to

# specifically define each indivial printer

[printers]

comment = All Printers

path = /var/spool/samba

browseable = no

# Set public = yes to allow user 'guest account' to print

guest ok = no

writable = no

printable = yes

# This one is useful for people to share files

;[tmp]

; comment = Temporary file space

; path = /tmp

; read only = no

; public = 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

# Other examples.

#

# A private printer, usable only by fred. Spool data will be placed in fred's

# home directory. Note that fred must have write access to the spool directory,

# wherever it is.

;[fredsprn]

; comment = Fred's Printer

; valid users = fred

; path = /home/fred

; printer = freds_printer

; public = no

; writable = no

; printable = yes

# A private directory, usable only by fred. Note that fred requires write

# access to the directory.

;[fredsdir]

; comment = Fred's Service

; path = /usr/somewhere/private

; valid users = fred

; public = no

; writable = yes

; printable = no

# a service which has a different directory for each machine that connects

# this allows you to tailor configurations to incoming machines. You could

# also use the %U option to tailor it by user name.

# The %m gets replaced with the machine name that is connecting.

;[pchome]

; comment = PC Directories

; path = /usr/local/pc/%m

; public = no

; writable = yes

# A publicly accessible directory, read/write to all users. Note that all files

# created in the directory by users will be owned by the default user, so

# any user with access can delete any other user's files. Obviously this

# directory must be writable by the default user. Another user could of course

# be specified, in which case all files would be owned by that user instead.

[public]

path = /home/detack/app/tomcat

public = yes

browseable = yes

writable = yes

printable = no

guest ok = yes

# The following two entries demonstrate how to share a directory so that two

# users can place files there that will be owned by the specific users. In this

# setup, the directory should be writable by both users and should have the

# sticky bit set on it to prevent abuse. Obviously this could be extended to

# as many users as required.

;[myshare]

; comment = Mary's and Fred's stuff

; path = /usr/somewhere/shared

; valid users = mary fred

; public = no

; writable = yes

; printable = no

; create mask = 0765

4. 搭建samba伺服器應該注意什麼

一般你裝系統的時候會默認安裝samba,如果沒有安裝,只需要運行這個命令安裝(CentOS):

「yum install -y samba samba-client」

Samba的配置文件為/etc/samba/smb.conf,通過修改這個配置文件來完成我們的各種需求。打開這個配置文件,你會發現很多內容都用」#」或者」;」注視掉了。先看一下未被注釋掉的部分:

[global]

workgroup = MYGROUP

server string = Samba Server Version %v

security = user

passdb backend = tdbsam

load printers = yes

cups options = raw

[homes]

comment = Home Directories

browseable = no

writable = yes

[printers]

comment = All Printers

path = /var/spool/samba

browseable = no

guest ok = no

writable = no

printable = yes

主要有以上三個部分:[global], [homes], [printers]。

[global]定義全局的配置,」workgroup」用來定義工作組,相信如果你安裝過windows的系統,你會對這個workgroup不陌生。一般情況下,需要我們把這里的」MYGROUP」改成」WORKGROUP」(windows默認的工作組名字)。

security = user #這里指定samba的安全等級。關於安全等級有四種:

share:用戶不需要賬戶及密碼即可登錄samba伺服器

user:由提供服務的samba伺服器負責檢查賬戶及密碼(默認)

server:檢查賬戶及密碼的工作由另一台windows或samba伺服器負責

domain:指定windows域控制伺服器來驗證用戶的賬戶及密碼。

passdb backend = tdbsam # passdb backend (用戶後台),samba有三種用戶後台:smbpasswd, tdbsam和ldapsam.

smbpasswd:該方式是使用smb工具smbpasswd給系統用戶(真實用戶或者虛擬用戶)設置一個Samba 密碼,客戶端就用此密碼訪問Samba資源。smbpasswd在/etc/samba中,有時需要手工創建該文件。

tdbsam:使用資料庫文件創建用戶資料庫。資料庫文件叫passdb.tdb,在/etc/samba中。passdb.tdb用戶資料庫可使用smbpasswd –a創建Samba用戶,要創建的Samba用戶必須先是系統用戶。也可使用pdbedit創建Samba賬戶。pdbedit參數很多,列出幾個主要的:

pdbedit –a username:新建Samba賬戶。

pdbedit –x username:刪除Samba賬戶。

pdbedit –L:列出Samba用戶列表,讀取passdb.tdb資料庫文件。

pdbedit –Lv:列出Samba用戶列表詳細信息。

pdbedit –c 「[D]」–u username:暫停該Samba用戶賬號。

pdbedit –c 「[]」–u username:恢復該Samba用戶賬號。

ldapsam:基於LDAP賬戶管理方式驗證用戶。首先要建立LDAP服務,設置「passdb backend = ldapsam:ldap://LDAP Server」

load printers 和 cups options 兩個參數用來設置列印機相關。

除了這些參數外,還有幾個參數需要你了解:

netbios name = MYSERVER # 設置出現在「網上鄰居」中的主機名

hosts allow = 127. 192.168.12. 192.168.13. # 用來設置允許的主機,如果在前面加」;」則表示允許所有主機

log file = /var/log/samba/%m.log #定義samba的日誌,這里的%m是上面的netbios name

max log size = 50 # 指定日誌的最大容量,單位是K

[homes]該部分內容共享用戶自己的家目錄,也就是說,當用戶登錄到samba伺服器上時實際上是進入到了該用戶的家目錄,用戶登陸後,共享名不是homes而是用戶自己的標識符,對於單純的文件共享的環境來說,這部分可以注視掉。

[printers]該部分內容設置列印機共享。

5. 怎樣在Linux系統搭建Samba共享伺服器

17.2. 配置 Samba 伺服器 默認的配置文件(/etc/samba/smb.conf)允許用戶作為 Samba 共享來查看他們的 Red Hat Linux 主目錄。它還把為 Red Hat Linux 配置的列印機作為 Samba 共享列印機來共享。換一句話說,你可以在你的 Red Hat Linux 系統上連接列印機,然後從網路上的 Windows 機器來列印。 17.2.1. 圖形化配置 要使用圖形化界面來配置 Samba,使用 Samba 伺服器配置工具。要使用命令行來配置,請跳到第 17.2.2 節。 Samba 伺服器配置工具是用來管理 Samba 共享、用戶、以及基本伺服器設置的圖形化界面。它修改 /etc/samba/ 目錄中的配置文件。沒有使用該程序進行的改變都會被保留。 要使用該程序,你必須在運行 X 窗口系統,具備根特權,並且安裝了 redhat-config-samba RPM 軟體包。要從桌面啟動 Samba 伺服器配置工具,點擊面板上的「主菜單」 => 「系統設置」 => 「伺服器設置」 => 「Samba 伺服器」,或在 shell 提示(如 XTerm 或 GNOME 終端)下鍵入 redhat-config-samba 命令。 圖 17-1. Samba 伺服器配置工具 注記 Samba 伺服器配置工具不顯示允許用戶在 Samba 伺服器上查看他們自己的主目錄的共享列印機或默認文件段。 17.2.1.1. 配置伺服器設置 配置 Samba 伺服器的第一步是配置伺服器的基本設置和幾個安全選項。啟動了應用程序後,選擇 「首選項」 => 「伺服器設置」。「基本」活頁標簽如 圖 17-2所示。 圖 17-2. 配置基本伺服器設置 在「基本」標簽上,指定計算機應在的工作組以及對計算機的簡短描述。它們與 smb.conf 中的 workgroup 和 server string 選項相對應。 圖 17-3. 配置安全伺服器設置 「安全」標簽包含以下選項: 「驗證模式」 — 它和 security 選項相對應。選擇以下驗證模式中的一種。 「域」 — Samba 伺服器依賴於 Windows NT 主要或備份域控制器來校驗用戶。伺服器把用戶名和口令傳遞給控制器,然後等待它們被返回。在「驗證伺服器」欄位中指定主要或備份域控制器的 NetBIOS 名稱。 「加密口令」選項如果被選,它必須被設置為「是」。

6. 怎麼在linux上搭建samba伺服器

SMB(Server MessagesBlock)協議:實現區域網內文件或列印機等資源共享服務的協議。

11.2 Samba服務

11.2.1 安裝服務程序

通過安裝Samba服務程序後細致的分析其配置文件參數,更能夠幫助讀者們理解Samba服務的安全驗證方式。

安裝Samba服務軟體包:

[root@linuxprobeDesktop]#yuminstallsamba
Loadedplugins:langpacks,proct-id,subscription-manager
………………省略部分安裝過程………………
Installing:
sambax86_644.1.1-31.el7rhel7527k
………………省略部分安裝過程………………
Complete!

瀏覽Samba配置文件:

[root@linuxprobe~]#cat/etc/samba/smb.conf

配置文件竟然有320行!有沒有被嚇到?其實Samba服務配置文件中大部分是注釋信息,我們可以來篩選過濾下:

備份原始的配置文件:

[root@linuxprobe~]#mv/etc/samba/smb.conf/etc/samba/smb.conf.bak

過濾掉無用的內容:
先使用cat命令讀入Smb配置文件後通過grep命令-v參數(反向選擇)去掉所有注釋信息,然後分別刪選掉包含#號的行("#"),包含;號的行(";")以及所有的空白行("^$"),最後最後將過濾後的信息覆蓋寫入到/etc/samba/smb.conf文件中。

cat/etc/samba/smb.conf.bak|grep-v"#"|grep-v";"|grep-v"^$">/etc/samba/smb.conf

讓我們來看看過濾後的配置文件吧:

[global]#全局參數。
workgroup=MYGROUP#工作組名稱。
serverstring=SambaServerVersion%v#伺服器介紹信息,參數%v為顯示SMB版本號。
logfile=/var/log/samba/log.%m#定義日誌文件存放位置與名稱,參數%m為來訪的主機名。
maxlogsize=50#定義日誌文件最大容量為50Kb。
security=user#安全驗證的方式,總共有4種。
#share:來訪主機無需驗證口令,更加方便,但安全性很差。
#user:需由SMB服務驗證來訪主機提供的口令後才可建立訪問,更加的安全。
#server:使用獨立的遠程主機驗證來訪主機提供的口令(集中管理帳號)。
#domain:使用PDC來完成驗證
passdbbackend=tdbsam#定義用戶後台的類型,共有3種。
#smbpasswd:使用SMB服務的smbpasswd命令給系統用戶設置SMB密碼。
#tdbsam:創建資料庫文件並使用pdbedit建立SMB獨立的用戶。
#ldapsam:基於LDAP服務進行帳戶驗證。
loadprinters=yes#設置是否當Samba服務啟動時共享列印機設備。
cupsoptions=raw#列印機的選項
[homes]#共享參數
comment=HomeDirectories#描述信息
browseable=no#指定共享是否在「網上鄰居」中可見。
writable=yes#定義是否可寫入操作,與"readonly"相反。
[printers]#列印機共享參數
comment=AllPrinters
path=/var/spool/samba#共享文件的實際路徑(重要)。
browseable=no
guestok=no#是否所有人可見,等同於"public"參數。
writable=no
printable=yes
標準的Samba共享參數是這樣的:
參數作用
[linuxprobe]共享名稱為linuxprobe
comment=警告用戶不要隨意修改資料庫
path=/home/database共享文件夾在/home/database
public=no關閉所有人可見
writable=yes允許寫入操作

後面的詳細配置可以參考《linux就該這么學》的第十一章,上面有詳細的介紹安裝和配置步驟,常用的安全級別有share、user,這種服務在企業和公司中用的還是比較多的。

7. Linux下如何搭建SAMBA伺服器

1、相關的文件
samba-common samba伺服器的主文件
samba 伺服器端的軟體
samba-client 客戶端的軟體
redhat-config-samba 圖形界面的配置文件
samba-swat web配置工具
2、步驟
1)安裝SAMBA伺服器
(1)檢測是否安裝samba
#rpm -qa | grep samba
(2)安裝:將第一張光碟放入光碟機
#mount /mnt/cdrom
#cd /mnt/cdrom/RedHat/RPMS
#ls samba*.*
#rpm -ivh samba-common-2.2.7a-7.9.0.i386.rpm
#rpm -ivh samba-2.2.7a-7.9.0.i386.rpm
#rpm -ivh samba-client-2.2.7a-7.9.0.i386.rpm
#cd /
#umount /mnt/cdrom
#eject
2)設置samba的密碼文件
(1)成批用戶密碼文件的生成
#cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd
(2)刪除一些無用的shell帳戶
#vi /etc/samba/smbpasswd
從1到9。
(3)設置目錄和文件的許可權
#chown root.root /etc/samba/smbpasswd
#chmod 500 /etc/samba
#chmod 600 /etc/samba/smbpasswd
#ll -d /etc/samba
(4)單個用戶設置samba密碼
#useradd wujianan
#passwd wujianan
#smbpasswd -a wujianan
3)啟動samba伺服器
#service smb start
#pstree | grep mbd
#smbclient -L localhost或者IP地址
4)配置samba的共享
#vi /etc/samba/smb.conf
[global]
workgroup = workgroup
server string = samba server
;hosts allow = 192.168.1. 192.168.2. 127.
printcap = /etc/printcap
load prints = yes
printing = cups
;guest account = pcguest
log file = /var/log/samba/%m.log
max log size = 0
安全選項
security = user(share)
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
;interfaces = 192.168.12.2/24 192.168.13.2/24
dns proxy = no
設置每個用戶主目錄共享
[homes]
comment = Home Directries
browseable = no 不允許瀏覽共享文件夾
writeable = yes 允許寫入
valid users = %s
create mode = 0664
directry mode = 0775
[printers]
comment = All prints
path = /var/spool/samba
browseable = no
printable = yes
[doc]
comment = doc
path = /home/doc
browseable = no
writeable = no或 read only = yes
guest ok = yes
示例:
要求:創建一個共享目錄,所有用戶都可訪問,許可權為只讀。
#vi /etc/samba/smb.conf
workgroup = workgroup
server string = samba server
netbios name = RH9
dos charset = cp936
unix charset = cp936
secrity = share
[read]
comment = read
path = /home/read
public = yes
guest ok = yes
read only = yes
保存退出
#mkdir /home/read
#service iptables stop
#service smb start
#testparm
\\ip地址
創建一個可寫的目錄,允許所有用戶可寫入。
[write]
comment = write
path = /home/write
public = yes
guest ok = yes
writeable = yes
保存退出
#mkdir /home/write
#chmod 777 /home/write
#service iptables stop
#service smb restart
為指定的用戶和組訪問samba伺服器
#useradd mehost
#passwd wujianan
#smbpasswd -a wujianan
#mkdir /var/samba/wujianan
#chown stu1.stu1 /var/samba/wujianan
#vi /etc/samba/smb.conf

security = user

[wujianan]
comment = wujianan
path = /var/samba/wujianan
valid users = wujianan
public = yes
writeable = yes
保存退出
#service smb restart
最簡單的電影伺服器的配置
#vi /etc/samba/smb.conf
workgroup = workgroup
server string = movies server
guest account = nobody
security = share
client code page = cp936
wins support = yes
[movies]
comment = movies
browseable = yes
writeable = no
path = /movies
guest ok = yes
read only = yes
保存退出
#mkdir /movies
#useradd admin -d movies
#passwd admin
#vi /etc/passwd
admin:x:0:500::/movies:/bin/bash
保存退出
#ntsysv
選擇smb和vsftp
#service smb start
#service vsftpd start
#service iptables stop

8. 筆記本怎麼搭建samba伺服器

1、首先需要登入安裝了Linux系統的計算機,安裝Samba。Fedora發行版一般使用yum工具安裝Samba伺服器,可以使用「rpm -q samba」查詢Samba伺服器是否已經安裝,當然,也可以直接使用「yum install samba」安裝Samba伺服器。如果Samba已經安裝,yum會給出提示,否則按照步驟,輸入「y」就可以直接下載安裝Samba伺服器了。
2、安裝完成之後,需要查看一下Samba是否已經加入到自啟動服務。使用「/sbin/chkconfig | grep smb」和「/sbin/chkconfig | grep nmb」命令可以查看smb和nmb是否加入到系統服務。(SMB是Samba共享服務,nmb是NetBIOS服務,為配合Windows使用,他們兩個服務都要加入到系統服務中)。然後再使用「/sbin/service smb status」和「/sbin/service nmb status」查看服務是否已經啟用。
3、接下來就要配置samba伺服器了。編輯修改「/etc/samba/smb.conf」,設置共享和認證參數。如圖就是我在用的Samba用戶共享典型配置文件。編輯修改完成之後,可以使用「testparm /etc/samba/smb.conf」驗證配置文件的有效性,以免因配置文件錯誤而導致Samba服務無法啟動。
4、驗證OK的話,接下來就是添加Samba共享用戶了,使用「/usr/bin/smbpasswd -a <用戶名稱>」的方式添加Samba共享用戶,並為每個用戶設置Samba共享認證的密碼。
5、到這里基本上Samba伺服器配置就完成了,如果上述步驟中smb和nmb服務沒有自動添加到系統服務中,可以使用「/sbin/chkconfig --level 2345 smb on」和「/sbin/chkconfig --level 2345 nmb on」將其加入到系統服務中,其中2345是Linux的運行級別,一般都不會超出這幾個運行級別。然後我們就可以使用「/sbin/service smb restart」和「/sbin/service nmb restart」重啟服務了。
6、重啟完成之後,Windows就可以訪問用戶共享了。在Windows資源管理器輸入「\\共享IP地址\共享用戶」,就可以訪問用戶自己目錄下的全部文件了。
7、為了測試共享許可權,我們進入用戶共享目錄,嘗試在Windows資源管理器中創建一個「test」目錄。
8、回到Linux的用戶目錄,我們就可以看到,Windows和Linux查看到的用戶共享目錄是一致的。(你可能覺得看到的文件和目錄說不一致,這是因為我的Windows設置了顯示隱藏文件和文件夾的緣故。)

9. 如何搭建samba伺服器

samba安裝和啟動

samba的源碼安裝採用最新版本samba-4.1.14,官網下載。安裝過程如下:

$ sudo mkdir /usr/local/samba-4.1.14
$ ./configure --prefix=/usr/local/samba-4.1.14
...
Checking for program xsltproc : not found
Checking for program python : /usr/bin/python
Checking for program python : /usr/bin/python
Checking for program python : /usr/bin/python
Checking for Python version >= 2.5.0 : ok 2.7.6
Checking for library python2.7 : not found
Checking for library python2.7 : yes
Checking for program python2.7-config : not found
Checking for program python-config-2.7 : not found
Checking
for custom code
: Could not find the python development headers
/home/anonymalias/Downloads/samba-4.1.14/wscript:100:
error: the configuration failed (see
'/home/anonymalias/Downloads/samba-4.1.14/bin/config.log')

上面錯誤的原因是samba必須依賴python,執行

$ sudo apt-get install python-dev

後面就是make && sudo make install,安裝ok後,安裝目錄結構如下:

/usr/local/samba-4.1.14$ ls
bin etc include lib private sbin share va

將源碼文件下默認的conf文件拷貝到安裝目錄下的etc目錄中

/usr/local/samba-4.1.14$ cp /home/anonymalias/Downloads/samba-4.1.14/examples/smb.conf.default etc/smb.conf

修改smb.conf中配置

global段添加如下欄位

[global]
...
netbios name = ubuntu

共享資源欄位採用默認配置

[homes]
comment = Home Directories
browseable = no
writable = yes

# NOTE: If you have a BSD-style print system there is no need to
# specifically define each indivial printer
[printers]
comment = All Printers
path = /usr/spool/samba
browseable = no
# Set public = yes to allow user 'guest account' to print
guest ok = no
writable = no
printable = yes

添加用戶名為Ubuntu的賬戶,

/usr/local/samba-4.1.14$ sudo bin/smbpasswd -a ubuntu
New SMB password:
Retype new SMB password:

samba伺服器的用戶是依賴於linux的用戶,只能添加linux中已存在的用戶,否則會出現如下錯誤:

/usr/local/samba-4.1.14$ sudo bin/smbpasswd -a user1
New SMB password:
Retype new SMB password:
Failed to add entry for user user1.

啟動samba 服務

/usr/local/samba-4.1.14$ sudo sbin/nmbd
/usr/local/samba-4.1.14$ sudo sbin/smbd

在Windwos文件管理器或直接win+R,輸入server ip,可以看到如下界面:

10. 如何部署Samba服務

你好,這里有一篇文章關於

Linux中samba伺服器的搭建

希望可以幫助到你!

熱點內容
兩個次梁相交怎麼配置 發布:2024-11-15 20:27:35 瀏覽:373
android關機實現 發布:2024-11-15 20:26:42 瀏覽:56
木糠壓縮原理 發布:2024-11-15 20:22:53 瀏覽:654
編譯原理難以理解的問題 發布:2024-11-15 20:11:25 瀏覽:130
安卓9是什麼水平 發布:2024-11-15 20:06:57 瀏覽:185
intel快速存儲ssd 發布:2024-11-15 20:00:27 瀏覽:143
吃雞配置太低怎麼調高畫質 發布:2024-11-15 19:58:19 瀏覽:735
王者怎麼設置來電屏蔽安卓 發布:2024-11-15 19:56:08 瀏覽:450
伺服器如何搭建多個ip 發布:2024-11-15 19:42:10 瀏覽:103
價錢低高配置的有哪些車 發布:2024-11-15 19:34:53 瀏覽:381