smb共享盘密码重置和无法ip访问问题

本文介绍如何在Ubuntu系统中设置共享文件夹,包括通过smbpasswd命令管理用户密码、配置smb.conf文件、解决常见问题等步骤,实现与Windows系统的文件共享。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Windows 可以通过crett 账号密码访问 Ubuntu 設置的共享目录。

重置密码的方法如下:

  1. sudo smbpasswd -a user  
  2. New SMB password:  
  3. Retype new SMB password:  


以下是 使账号 crett 失效:

  1. $ sudo smbpasswd -d crett
  2. [sudo] password for user:   
  3. Disabled user crett.  

去除添加的账号:

  1. $ sudo smbpasswd -x crett  
  2. Deleted user crett.  

以下是 smbpasswd 的說明:
  1. $ smbpasswd -h  
  2. When run by root:  
  3.     smbpasswd [options] [username]  
  4. otherwise:  
  5.     smbpasswd [options]  
  6.   
  7. options:  
  8.   -L                   local mode (must be first option)  
  9.   -h                   print this usage message  
  10.   -s                   use stdin for password prompt  
  11.   -c smb.conf file     Use the given path to the smb.conf file  
  12.   -D LEVEL             debug level  
  13.   -r MACHINE           remote machine  
  14.   -U USER              remote username  
  15. extra options when run by root or in local mode:  
  16.   -a                   add user  
  17.   -d                   disable user  
  18.   -e                   enable user  
  19.   -i                   interdomain trust account  
  20.   -m                   machine trust account  
  21.   -n                   set no password  
  22.   -W                   use stdin ldap admin password  
  23.   -w PASSWORD          ldap admin password  
  24.   -x                   delete user  
  25.   -R ORDER             name resolve order  

----------查看smb配置信息---------------

vi /etc/samba/smb.conf

251
252 [share]
253         comment = Shared Folder require password
254         path = /home/crett/share
255         public = yes
256         writable = yes
257         valid users = our
258         create mask = 0777
259         directory mask = 0777
260         force user = nobody
261         force group = nogroup
262         available = yes
263         browseable = yes

1、保存后重新启动samba,sudo /etc/init.d/samba restart

2、设置用户和密码   sudo smbpasswd -a crett 接着俺提示输入密码。

3、最后windows下网上邻居->右键->映射网络驱动器
输入 文件夹框 \\ip地址\ShareFiles,按提示输入用户名密码即可。


ip访问smb服务端,出现无法访问现象

1、开启设置局域网文件和打印机共享,关闭网络防火墙

----------------------------------------------

增加samba用户提示Failed to add entry for user

[root@ubuntu ~]# smbpasswd -a test
New SMB password:
Retype new SMB password:
Failed to add entry for user test.


解决办法:
这是因为没有加相应的系统账号,所以会提示Failed to add entry for user的错误,只需增加相应的系统账号test就可以了:
[root@ubuntu ~]# groupadd test -g 6000
[root@ubuntu ~]# useradd test -u 6000 -g 6000 -s /sbin/nologin -d /dev/null


这时就可以用smbpasswd -a test增加test这个samba账号了!为了增加系统的安全性,所以加的系统账号不要给shell它,也不给它指定目录,到时在/home目录给test账号建个文件夹,该文件夹只有test有读写权限即可!
如:
[root@ubuntu ~]# mkdir /home/test
[root@ubuntu ~]# chown -R test:test /home/test


若不想让另人访问,只让test用户可以访问,只需执行命令:
[root@ubuntu ~]# chmod u+rwx,g+rwx,o-rwx /home/test


这时可以用smbpasswd命令增加 samba账号test了
[root@ubuntu ~]# smbpasswd -a test
New SMB password:
Retype new SMB password:
Added  user test.


-----------------------==========-----------========-----------==========------------------


另外,介紹下 ubuntu 系統给 windlows 共享文件夹方法:

选中要共享的文件夹,

右键选properties,

在share 一栏,勾上"share this folder",

点击 Modify,

就可以进行文件夹的共享了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值