Linux服务器---配置samba

简介:
配置samba使用用户名和密码登录
1、当samba配置文件中的secure设置为user的时候,需要正确的用户名和密码才能登录。
      root@localhost /]#  gedit /etc/samba/smb.conf
      # ----------------------- Standalone Server Options ------------------------
      # Scurity can be set to user, share(deprecated) or server(deprecated)
      # Backend to store user information in. New installations should 
      # use either tdbsam or ldapsam. smbpasswd is available for backwards 
      # compatibility. tdbsam requires no further configuration
security = user           //这是默认值,需要用户名密码
passdb backend = tdbsam


2、管理账户和密码
      samba默认使用tdbsam数据库管理机制来统一管理用户名和密码,使用的命令是pdbedit,命令如下
      pdbedit -L
            列出samba用户列表
      pdbedit -Lv
            列出samba用户详细信息
      pdbedit -Lw
            列出smbpasswd格式的用户
      pdbedit –a wj
            增加用户wj
      pdbedit –x wj
            删除用户wj
      pdbedit –c “[D]” –u wj
            暂停用户wj
      pdbedit –c “[]” –u wj
            恢复用户wj

3、添加用户,必须确保这个用户存在于你的Linux系统中
      [root@localhost wj]#  pdbedit -a david    //添加用户david
      new password:
      retype new password:
      Unix username:        david
      NT username:          
      Account Flags:        [U          ]
      User SID:             S-1-5-21-1098217942-694112815-2930643030-1000
      Primary Group SID:    S-1-5-21-1098217942-694112815-2930643030-513
      Full Name:            david
      Home Directory:       \\localhost\david
      HomeDir Drive:        
      Logon Script:         
      Profile Path:         \\localhost\david\profile
      Domain:               LOCALHOST
      Account desc:         
      Workstations:         
      Munged dial:          
      Logon time:           0
      Logoff time:          never
      Kickoff time:         never
      Password last set:    三, 15 8月 2018 10:15:21 CST
      Password can change:  三, 15 8月 2018 10:15:21 CST
      Password must change: never
      Last bad password   : 0
      Bad password count  : 0
      Logon hours         : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

      [root@localhost wj]#  pdbedit -L    //查看是否添加成功
      david:500:david

4、重启smb服务
      [root@localhost wj]#  gedit /etc/sysconfig/iptables
       -A INPUT -m state --state NEW -m tcp -p tcp --dport 137 -j ACCEPT
      -A INPUT -m state --state NEW -m tcp -p tcp --dport 138 -j ACCEPT
      -A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
      -A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT


      [root@localhost wj]#  service iptables restart
      iptables:将链设置为政策 ACCEPT:filter nat                [确定]
      iptables:清除防火墙规则:                                 [确定]
      iptables:正在卸载模块:                                   [确定]
      iptables:应用防火墙规则:                                 [确定]
      iptables:载入额外模块:nf_conntrack_ftp                   [确定]

5、启动smb服务
      [root@localhost wj]#  service smb restart
      关闭 SMB 服务:                                            [确定]
      启动 SMB 服务:                                            [确定]
      [root@localhost wj]# 

6、从windows测试,按下快捷键“window+r”,在弹出的窗口输入命令“smb:\\192.168.0.113”,要求输入用户名和密码,匿名用户也无法登陆。
      
      
      用户登录后,只能查看自己的家目录,不能选择其他目录
      
      
相关文章
|
13天前
|
消息中间件 安全 Unix
SSH配置多台服务器之间的免密登陆以及登陆别名
SSH配置多台服务器之间的免密登陆以及登陆别名
25 1
|
17天前
|
Java Linux
Springboot 解决linux服务器下获取不到项目Resources下资源
Springboot 解决linux服务器下获取不到项目Resources下资源
|
17天前
|
网络协议 Linux
在Linux中,管理和配置网络接口
在Linux中管理网络接口涉及多个命令,如`ifconfig`(在新版本中被`ip`取代)、`ip`(用于网络设备配置)、`nmcli`(NetworkManager的CLI工具)、`nmtui`(文本界面配置)、`route/ip route`(处理路由表)、`netstat/ss`(显示网络状态)和`hostnamectl/systemctl`(主机名和服务管理)。这些命令帮助用户启动接口、设置IP地址、查看连接和路由信息。不同发行版可能有差异,建议参考相应文档。
19 4
|
2天前
|
监控 Linux 网络安全
Linux服务器如何查询连接服务器的IP
【4月更文挑战第15天】Linux服务器如何查询连接服务器的IP
9 1
|
2天前
|
Ubuntu Linux
Linux(Ubuntu)系统临时IP以及静态IP配置(关闭、启动网卡等操作)
请注意,以上步骤是在临时基础上进行配置的。如果要永久保存静态IP地址,通常还需要修改 `/etc/network/interfaces`文件,以便在系统重启后保持配置。同时,确保备份相关配置文件以防止出现问题。
9 1
|
2天前
|
监控 安全 Linux
Linux系统之安装ServerBee服务器监控工具
【4月更文挑战第22天】Linux系统之安装ServerBee服务器监控工具
40 2
|
3天前
|
Ubuntu Linux 测试技术
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试(下)
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试
33 1
|
3天前
|
运维 网络协议 Linux
Linux(28) Linux双网卡配置为连接到Linux主机的PC提供外网访问
Linux(28) Linux双网卡配置为连接到Linux主机的PC提供外网访问
27 1
|
3天前
|
Ubuntu 网络协议 Linux
Linux(20) Ubuntu 20.04 网络接口自动切换路由配置
Linux(20) Ubuntu 20.04 网络接口自动切换路由配置
27 0
|
3天前
|
Linux
Linux(9)Debain EC25 quectel-CM usbnet0开机自动联网配置
Linux(9)Debain EC25 quectel-CM usbnet0开机自动联网配置
15 0