smb

https://www.howtoforge.com/tutorial/debian-samba-server/

This tutorial explains the installation of a Samba fileserver on Debian 8 (Jessie) and how to configure it to share files over the SMB protocol as well as how to add users. Samba is configured as a standalone server, not as a domain controller. In the resulting setup, every user has his own home directory accessible via the SMB protocol and all users have a shared directory with read-/write access.

1 Preliminary Note

I‘m using a Debian 8 system here with the hostname debian.example.com and the IP address 192.168.1.100.

I will use the nano editor in this tutorial to edit config files on the shell. Nano can be installed with the command:

apt-get install nano

If you have a different favorite shell editor like joe or vi, then use that instead.

To make the Linux server accessible by name from my Windows workstation, I will add a line to the hosts file on Windows. Run this command as Administrator user on Windows:

notepad C:\Windows\System32\drivers\etc\hosts

and add a line like this:

192.168.1.100 	debian.example.com	debian

at the end of the file. Replace the IP address with the server IP and the hostname with the hostname that you have chosen for your server.

2 Installing Samba

Connect to your server on the shell as root user and install the Samba packages:

apt-get install libcups2 samba samba-common cups

Move the current smb.conf file to smb.conf.bak:

mv /etc/samba/smb.conf /etc/samba/smb.conf.bak

And then create a new file smb.conf file:

nano /etc/samba/smb.conf

With the following content:

[global]workgroup = WORKGROUPserver string = Samba Server %vnetbios name = debiansecurity = usermap to guest = bad userdns proxy = no

Replace WORKGROUP with the workgroup name that is used on your Windows clients. If you don‘t know the name of the workgroup, run this command on the Windows client to get the workgroup name:

net config workstation

Then close the Samba configuration file on the server and restart Samba:

systemctl restart smbd.service

3 Adding Samba Shares

Now I will add a share that is accessible by all users.

Create the directory for sharing the files and change the group to the users group:

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

mkdir -p /home/shares/anonymous
chown -R root:users /home/shares/anonymous/
chmod -R ug+rwx,o+rx-w /home/shares/anonymous/

At the end of the file /etc/samba/smb.conf add the following lines:

nano /etc/samba/smb.conf

3.1 Group share

This is a share that is accessible and writable for all members of our "users" group. Add the following config at the end of the smb.conf file.

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

3.2 Home directories

If you want all users to be able to read and write to their home directories via Samba, add the following lines to /etc/samba/smb.conf (make sure you comment out or remove the existing [homes] section):

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

3.3 Anonymous share

You like to have a share were all users in your network can write to? Be careful, this share is open to anyone in the network, so use this only in local networks. Add an anonymous share like this:

[anonymous]
   path = /home/shares/anonymous
   force group = users   create mask = 0660   directory mask = 0771   browsable =yes
   writable = yes
   guest ok = yes

Now we restart Samba:

systemctl restart smbd.service

4 Adding and Managing Users

In this example, I will add a user named tom. You can add as many users as you need, in the same way, just replace the username tom with the desired username in the commands.

useradd tom -m -G users

Set a password for tom in the Linux system user database. If the user tom should not be able to log into the Linux system, skip this step.

passwd tom

-> Enter the password for the new user.

Now add the user to the Samba user database:

smbpasswd -a tom

-> Enter the password for the new user.

Now you should be able to log in from your Windows workstation with the file explorer (address is \\192.168.1.100 or \\192.168.1.100\tom for tom‘s home directory) using the username tom and the chosen password and store files on the Linux server either in tom‘s home directory or in the public shared directory.

5 Accessing Samba from Windows

Now you can access the samba shares from your Windows Desktop. Open the command prompt and enter "//debian" to open a file explorer:

That shows the shares of our samba server.

6 Links

时间: 2024-08-05 11:13:41

smb的相关文章

windows 10 smb,添加网络位置,输入的文件夹似乎无效

在windows 10中遇到一个现象,在"添加一个网络位置"的时候,弹出"输入的文件夹似乎无效.请选择另一个",我在这里是需要连接到Linux上的smb指定目录,经其它机子测试,smb服务器正常,输入的参数也正常.从smb服务器日志中也没有发现异常现象. 经过多次尝试,发现应该是在访问网络位置的时候,使用的用户及密码不对.由于登录了微软账户,默认使用微软用户进行访问的,所以导致无法访问. 解决方法: 1.改为添加"映射网络驱动器": 2.勾选&q

Linux与云计算——第二阶段 第十章:Samba服务器架设—SMB共享目录及多用户SMB挂载

Linux与云计算--第二阶段Linux服务器架设 第十章:Samba服务器架设-SMB共享目录及多用户SMB挂载 通过SMB共享目录 在Server上配置SMB服务 您的SMB服务器必须是STAFF工作组的一个成员 共享/common目录 共享名必须为common 只有example.com域内的客户端可以访问common共享 common必须是可以浏览的 用户andy必须能够读取共享中的内容,如果需要的话,验证密码是redhat [1] 安装配置Samba. [[email protecte

ShadowBroker公开的SMB远程命令执行漏洞修复

漏洞编号为ms17-010,如何查看对应MS号的补丁已经安装: 下载微软官方的补丁信息列表 http://download.microsoft.com/download/6/7/3/673E4349-1CA5-40B9-8879-095C72D5B49D/BulletinSearch.xlsx 执行systeminfo,查看是否有KB4013389补丁. Date Posted Bulletin Id Bulletin KB Severity Impact Title Affected Prod

Linux SMB和NFS文件共享

一.smb文件共享 1.安装和为smb添加用户 1.1安装smb软件 yum install samba samba-common samba-client-y systemctl start smb nmb systemctl enable smb nmb 1.2为smb添加用户 smb用户必须时本地用户 smbpasswd -a student New SMB password:      #输入smb当前用户密码 Retype new SMB password:  #确认密码   pdbe

UWP开发技巧:实现SMB协议操作文件服务器文件

问题来源 文件服务器文件夹操作在PC与Surface端确实还是和传统操作一样没什么区别,但是到了手机端与Surface Hub就没那么方便了,因为文件资源管理器Explorer根本没法添加网路硬盘.对于传统行业以及担心云端文件安全的企业固然还是希望能使用文件服务器,特别是SurfaceHub用户.SurfaceHub用户开会的时候会用到很多敏感文件,这个时候如果无法访问内部机密文件服务器,那还有什么用处? 解决方法 由于SurfaceHub只能安装UWP应用,自然首先考虑UWP的实现.目前支持S

Windows Server之浅谈SMB以及SMB小案例分享

SMB由来 服务器消息区块(英语:Server Message Block,缩写为SMB,服务器消息区块),又称网络文件共享系统(英语:Common Internet File System,缩写为CIFS),一种应用层网络传输协议,由微软开发,主要功能是使网络上的机器能够计算机文件.打印机.串行端口和通讯等资源.它也提供经认证的进程间通信机能.它主要用在装有Microsoft Windows的机器上,在这样的机器上被称为Microsoft Windows Network. SMB版本 OS W

【NFS服务器配置】【(CIFS)SMB】

**********************************************        ********************NFS服务器配置***************        ***********************************************类UNIX/etc/exports 示例/var/ftp/pub    192.168.0.0/24(ro,sync)         [()与前面不能空开,要是有,则表示 前面的只读,其它主机都

linux下smb文件共享服务器详解

1.smb服务器,netbios工作端口137/udp,138/udp,139/tcp,共享文件工作端口445/tcp 2.smb服务器主要是运行在linux与windows之间的文件共享服务, 安全级别有user,share,server,domain四种 user:相当于使用用户认证 share:相当于匿名访问 server:相当于在另一台服务器上用户认证 domain:相当于使用windows AD域用户认证 3.smb认证用户有3种,分为本地系统,非本地服务器上的帐号和windows的A

linux开机启动smb服务

修改/etc/rc.local文件(增加红色部分) [[email protected] ~]# cat /etc/rc.local #!/bin/sh## This script will be executed *after* all the other init scripts.# You can put your own initialization stuff in here if you don't# want to do the full Sys V style init stuf

Ubuntu下配置smb服务器

一. samba的安装: sudo apt-get insall samba 二. 创建共享目录: mkdir /home/user/share sodu chmod 777 /home/user/share 三. 创建Samba配置文件: 1. 保存现有的配置文件 sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak 2. 修改现配置文件 sudo gedit /etc/samba/smb.conf 在smb.conf最后添加 [share]