歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 在Debian Squeeze下安裝配置SAMBA

在Debian Squeeze下安裝配置SAMBA

日期:2017/2/28 16:21:19   编辑:Linux教程

Samba可以使我們在Linux和Windows計算機間分享文件。在目前的版本(v3),不僅可存取及分享SMB的資料夾及印表機,本身還可以整合到Windows Server的網域、扮演為網域控制站(Domain Controller)以及加入Active Directory成員。簡而言之,可用該應用在Windows與UNIX系列OS之間搭起一座橋梁,讓兩者的資源可互通有無。

下面為大家介紹如何在Debian Squeeze下安裝配置SAMBA。

#1
假定服務器IP為:192.168.58.142

#2安裝Samba
打開終端,輸入命令,安裝Samba及相關依賴:

sudo apt-get install libcupsys2 samba samba-common

你會遇到下面的問題:

Workgroup/Domain Name:

這裡我們填寫一個工作組的名字即可。

編輯smb.conf文件,使用命令:

vi /etc/samba/smb.conf

下面激活行“security = user”,讓Linux操作系統可以

[...]
# “security = user” is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
security = user
[...]


保存文件,退出,重啟Samba

/etc/init.d/samba restart

#3 添加Samba分享
創建文件分享目錄,向用戶組開放:

mkdir -p /home/samba-share/allusers
chown -R root:users /home/samba-share/allusers/
chmod -R ug+rwx,o+rx-w /home/samba-share/allusers/

在文件 /etc/samba/smb.conf添加下面行,
首先,使用命令,打開:

vi /etc/samba/smb.conf

接下來,添加下面內容:

[allusers]
comment = All Users
path = /home/samba-share/allusers
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
writable = yes

如果你希望所有的用戶可以通過Samba服務器來讀、寫他們的主目錄,可以在文件 /etc/samba/smb.conf 添加下面的內容:

[...]
[homes]
comment = Home Directories
browseable = no
valid users = @users
writable = yes
create mask = 0700
directory mask = 0700

然後保存,重啟Samba服務器:

/etc/init.d/samba restart

不要忘記設置配置文件為只讀:{這個地方有點不懂,原文講的是“Dont forget to set read only to noin the config file”}

# 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

#4 添加、管理用戶
比如,添加用戶Bentutu,命令如下:

useradd Bentutu -m -G users

為Bentutu設置密碼:

root@oss:~# passwd Bentutu

Enter new UNIX password:
Retype new UNIX password:

現在把Bentutu添加到Samba用戶數據庫:

root@oss:~# smbpasswd -a Bentutu
Output
New SMB password:
Retype new SMB password:
Added user Bentutu.
root@oss6:~#

現在,就可以從文件管理器登錄了,別忘了地址{地址是\\192.168.58.142或者\\192.168.58.142\Bentutu},其中Bentutu為你設置的用戶名。

Copyright © Linux教程網 All Rights Reserved