包含cups4jserver的詞條

本文目錄一覽:

win7系統如何配置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]該部分內容設置印表機共享。

【samba實踐】

注意:在試驗之前,請先檢測selinux是否關閉,否則可能會試驗不成功。關於如何關閉selinux請查看第十五章 linux系統日常管理的「linux的防火牆」部分

1. 共享一個目錄,任何人都可以訪問,即不用輸入密碼即可訪問,要求只讀。

打開samba的配置文件/etc/samba/smb.conf

[global]部分

把」MY GROUP」改成」WORKGROUP」

把」security = user」 修改為「security = share」

然後在文件的最末尾處加入以下內容:

[share]

comment = share all

path = /tmp/samba

browseable = yes

public = yes

writable = no

mkdir /tmp/samba

chmod 777 /tmp/samba

啟動samba服務

/etc/init.d/smb start

測試:

首先測試你配置的smb.conf是否正確,用下面的命令

testparm

如果沒有錯誤,則在你的windows機器上的瀏覽器中輸入 看是否能訪問

2. 共享一個目錄,使用用戶名和密碼登錄後才可以訪問,要求可以讀寫

打開samba的配置文件/etc/samba/smb.conf

[global] 部分內容如下:

[global]

workgroup = WORKGROUP

server string = Samba Server Version %v

security = user

passdb backend = tdbsam

load printers = yes

cups options = raw

然後加入以下內容:

[myshare]

comment = share for users

path = /samba

browseable = yes

writable = yes

public = no

保存配置文件,創建目錄:

mkdir /samba

chmod 777 /samba

然後添加用戶。因為在[globa]中」 passdb backend = tdbsam」,所以要使用」 pdbedit」 來增加用戶,注意添加的用戶必須在系統中存在。

useradd user1 user2

pdbedit -a user1 # 添加user1賬號,並定義其密碼

pdbedit -a user2

pdbedit -L # 列出所有的賬號

測試:

打開IE瀏覽器輸入 然後輸入用戶名和密碼

3. 使用linux訪問samba伺服器

Samba服務在linux下同樣可以訪問。前提是你的linux安裝了samba-client軟體包。安裝完後就可以使用smbclient命令了。

smbclient //IP/共享名 -U 用戶名

如:[root@localhost]# smbclient //10.0.4.67/myshare/ -U user1

Password:

Domain=[LOCALHOST] OS=[Unix] Server=[Samba 3.0.33-3.29.el5_6.2]

smb: \

出現如上所示的界面。可以打一個」?」列出所有可以使用的命令。常用的有cd, ls, rm, pwd, tar, mkdir, chown, get, put等等,使用help + 命令可以列印該命令如何使用,其中get是下載,put是上傳。

另外的方式就是通過mount掛載了:

如:

mount -t cifs //10.0.4.67/myshare /mnt -o username=user1,password=123456

格式就是這樣,要指定-t cifs //IP/共享名本地掛載點 -o後面跟username 和 password

掛載完後就可以像使用本地的目錄一樣使用共享的目錄了。

Ubuntu怎麼查看誰調用的cupsd

sudo service cups stop

sudo rm /etc/cups/subscriptions.conf*

sudo rm -r /var/cache/cups

sudo service cups start

如何在Ubuntu伺服器上設置Web配置的列印伺服器使用SWAT,CUPS和SAMBA

1、安裝有關Samba的RPM包(samba、samba-common、samba-client)

2、創建Samba用戶

3、修改配置文件

4、重啟samba服務

5、設置目錄訪問許可權

6、測試

具體步驟如下:

1、安裝RPM包(預設情況下RHEL5安裝了samba的相關軟體包,可以用如下命令查看)

[root@localhost ~]#rpm -qa | grep samba

samba —–samba伺服器程序的所有文件

samba-common —–提供了Samba伺服器和客戶機中都必須使用的公共文件

samba-client —–提供了Samba客戶機的所有文件

samba-swat —–以Web界面的形式提供了對Samba伺服器的管理功能

2、創建samba用戶

[root@localhost ~]#smbpasswd -a user1 (「-a」是創建samba用戶,「-x」是刪 [root@localhost ~]#smbpasswd -a user2 除samba用戶,「-d」是禁用samba用

[root@localhost ~]#smbpasswd -a user3 戶帳號,「-e」是啟用samba用戶帳號)

3、修改配置文件

samba配置文件的位置:/etc/samba/smb.conf

[root@localhost ~]#vim /etc/samba/smb.conf

Vi大開配置文件後,首先介紹一下Samba伺服器的安全級別,如圖所示:系統默認設置「user」

Samba伺服器的安全級別分為5種,分別是user、share、server、domain和ads。在設置不同的級別時,samba伺服器還會使用口令伺服器和加密口令。

1、user —–客戶端訪問伺服器時需要輸入用戶名和密碼,通過驗證後,才能使用伺服器的共享資源。此級別使用加密的方式傳送密碼。

2、share —–客戶端連接伺服器時不需要輸入用戶名和密碼

3、server —–客戶端在訪問時同樣需要輸入用戶名和密碼,但是,密碼驗證需要密碼驗證伺服器來負責。

4、domain —–採用域控制器對用戶進行身份驗證

5、ads —–若samba伺服器加入到Windows活動目錄中,則使用ads安全級別,ads安全級別也必須指定口令伺服器

共享目錄的配置

[homes] —–samba用戶的宿主目錄

comment = Home Directories —–設置共享的說明信息

browseable = no —–目錄瀏覽許可權

writable = yes —–用戶對共享目錄可寫

這個共享目錄只有用戶本身可以使用,默認情況下,用戶主目錄位於/home目錄下,每個Linux用戶有一個以用戶名命名的子目錄。

以下是共享印表機的設置:

[printers] —–共享印表機

comment = All Printers —–設置共享的說明信息

path = /var/spool/samba —–指定共享目錄的路徑

browseable = no —–目錄瀏覽許可權

guest ok = no —–允許來賓訪問

writable = no —–用戶對共享目錄可寫

printable = yes —–可以列印

以上是系統默認設置

添加自定義的共享目錄:( user1對/ASUS有所有權,user2擁有隻讀許可權,其他用戶不能訪問;public共享目錄允許所有用戶訪問及上傳文件)

[ASUS]

comment = user1 Directories —–設置共享的說明信息

browseable = yes —–所有samba用戶都可以看到該目錄

writable = yes —–用戶對共享目錄可寫

path = /ASUS —–指定共享目錄的路徑

[public]

comment = all user Directories —–設置共享的說明信息

browseable = yes —–所有samba用戶都可以看到該目錄

writable = yes —–用戶對共享目錄可寫

path = /public —–指定共享目錄的路徑

guest ok = yes —–允許來賓訪問

4、修改完配置文件後需要重啟samba服務

[root@localhost ~]#service smb restart

Samba伺服器包括兩個服務程序

2 smbd

? smbd服務程序為客戶機提供了伺服器中共享資源的訪問

2 nmbd

? nmbd服務程序提供了NetBIOS主機名稱的解析,為Windows網路中域或者工作組內的主機進行主機名稱的解析

5、設置目錄許可權

[root@localhost ~]#mkdir /ASUS ——創建要共享目錄

[root@localhost ~]#mkdir /public ——創建要共享的目錄

[root@localhost ~]#chmod 750 /ASUS ——修改/ASUS許可權(屬主擁有

所有權,屬組只讀,其它用戶不能訪問)

[root@localhost ~]#chown user1 /ASUS ——將/ASUS的屬主改為user1

[root@localhost ~]#groupadd ASUS ——添加ASUS組

[root@localhost ~]#usermod –G ASUS user1 ——將user1加入到ASUS組

[root@localhost ~]#usermod –G ASUS user2 ——將user2加入到ASUS組

[root@localhost ~]#chgrp ASUS /ASUS ——將/ASUS的屬組改為

ASUS

[root@localhost ~]#chmod 777 /public ——給所有用戶分配完全控制

許可權

配置完成後,還要檢查/etc/service文件中以「netbios」開頭的記錄,正確的文件

記錄如下所示,如果這些記錄前有#或沒有這些記錄,應手工添加,否則用戶無

法訪問Linux伺服器上的共享資源

6、測試

找一台內網windows客戶端,打開「網上鄰居 」,輸入samba伺服器的IP點擊

「搜索」

如圖所示:已經搜索到

雙擊打開,如圖所示:提示輸入用戶名和密碼,先來輸入user1的用戶名和密碼

作測試。

登錄成功,

打開user1的宿主目錄,此目錄user1是擁有所有許可權的,創建一個目錄測試一

下,如圖所示:可以創建

Public目錄是允許任何用戶上傳、下載及刪除文件,如圖所示

User1對ASUS目錄擁有完全控制許可權,所以user1可以在此目錄下作任何操作

切換另一個用戶測試,由於我們在同一台計算機上作測試,測試之前首先要清楚

計算機上的緩存,如圖所示:打開 「命令提示符模式」,「net use /del *」是清

除計算機上緩存

重新打開網上鄰居,找到Samba 伺服器的共享資源,以user2的身份登錄

以下幾幅圖片可以看到,user2對ASUS目錄擁有隻讀許可權,對public、user2目

錄擁有所有權

再切換一個用戶登錄,記得要清除緩存哦,輸入user3的用戶名及密碼

如圖所示:user3無法訪問ASUS目錄

User3隻對user3和public目錄擁有所有權

redhat enterprise 如何配置samba伺服器

/etc/samba/smb.conf主配置文件,此文件中有豐富的說明注釋

使用smbpasswd命令使Linux系統用戶成為Samba用戶,命令格式如下:

smbpasswd –a 用戶名

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 many any basic syntactic errors.

#

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

[global]

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

workgroup = Workgroup ;計算機所在的工作組名或域名

netbios name = fileserver ;即在,網上鄰居中顯示的計算機名

# server string is the equivalent of the NT Description field

server string = Samba Server ;計算機描述

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. ;允許訪問的計算機的IP地址

; hosts allow = 172.16.0. 172.16.3. 127.

# if you want to automatically load your printer list rather

# than setting them up individually then you’ll need this

; printcap name = /etc/printcap載入印表機的配置路徑

load printers = no是否將印表機共享

# 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

; printing = cups一種列印驅動模式,即LINUX支持的標準列印類型。其LINUX支持的列印類型有bsd, sysv, plp, lprng, aix, hpux, qnx

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

# otherwise the user “nobody” is used

; guest account = nobody

guest account = guest ;允許訪問(不需要用戶名與密碼)也可以指定任何系統內置的一個帳號做為來賓帳號。

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

# that connects

log file = /var/log/samba/%m.log.會給用戶在此目錄下做每個SAMBA用戶登錄的日誌。

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

max log size = 50日誌 文件限制在50K內

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

# security_level.txt for details.

security = share

; security = user

# Use password server option only with security = server

; password server = NT-Server-Name此行的作用為如果上面的選項為SERVER,則SAMBA伺服器在做身份識別的時候,把WIN機器發過來的密碼同用戶名交給此項設定的密碼伺服器驗證。

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

# all combinations of upper and lower case.

; password level = 8

; username level = 8(對於從前的幾款老式的WINDOWS系統對於大小寫密碼支持的不是很好,所以開啟上面的兩個參數的意義是在密碼為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(加密明文的SAMBA密碼進行發送)

smb passwd file = /etc/samba/smbpasswd驗證密碼所在的目錄

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

# update the Linux sytsem 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.

# Windows Internet Name Serving Support Section:

# WINS Support – Tells the NMBD component of Samba to enable it’s WINS Server

; wins support = yes把該伺服器配置為WINS伺服器

# 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 = 192.168.1.100也可以指定一個WINS伺服器,讓自己成為WINS客戶

# 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

(整個上面這段為討論與WINDWOS文件系統的大小寫問題因為微軟的系統是一個大小寫不區分 的系統,默認用默認值即可。因為修改可能造成與WINDOWS的不兼容問題)

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

[homes]作為登錄用戶,自己訪問自己目錄的設置。

; comment = Home Directories目錄說明

; browseable = no用戶私人目錄不需要給別人瀏覽。

; writable = yes也可以用read only=no來替代

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

; [netlogon]域用戶登錄目錄設置。

; comment = Network Logon Service

; path = /home/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 = /home/profiles

; browseable = no

; guest ok = yes

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

# specifically define each individual 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/soft

public = yes

guest ok = yes以上兩個public=yes代表來賓帳號能訪問此共享目錄,但guest ok代表密碼不是必須的,可以不加。

writable = yes

printable = no

write list = @staff此參數告訴我們不必要讓所有人訪問共享目錄,可以有staff這個組的成員能訪問,但在passwd和shadow文件中要存在這個組。

# 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 = /homes/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] (為創建一個私有目錄,別人都不能訪問,只有fred這個用戶能訪問)

; 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/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 = /usr/somewhere/else/public

; public = yes

; only guest = yes

; writable = yes

; printable = no

# 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

最後建議在圖形界面配置比較簡單

在LINUX提示符下輸入startx

即可進入圖形界面 和WINDOWS差不多 窗口化的配置比較直觀也比較簡單

原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/309843.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
小藍的頭像小藍
上一篇 2025-01-04 19:31
下一篇 2025-01-04 19:31

相關推薦

發表回復

登錄後才能評論