怎么配置samba服务器

2025年03月24日 07:07
有1个网友回答
网友(1):

1.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 individual 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,可以看到如下界面: