重置密码的方法如下:
- sudo smbpasswd -a user
- New SMB password:
- Retype new SMB password:
以下是 使账号 crett 失效:
- $ sudo smbpasswd -d crett
- [sudo] password for user:
- Disabled user crett.
去除添加的账号:
- $ sudo smbpasswd -x crett
- Deleted user crett.
以下是 smbpasswd 的說明:
- $ smbpasswd -h
- When run by root:
- smbpasswd [options] [username]
- otherwise:
- smbpasswd [options]
- options:
- -L local mode (must be first option)
- -h print this usage message
- -s use stdin for password prompt
- -c smb.conf file Use the given path to the smb.conf file
- -D LEVEL debug level
- -r MACHINE remote machine
- -U USER remote username
- extra options when run by root or in local mode:
- -a add user
- -d disable user
- -e enable user
- -i interdomain trust account
- -m machine trust account
- -n set no password
- -W use stdin ldap admin password
- -w PASSWORD ldap admin password
- -x delete user
- -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,
就可以进行文件夹的共享了。