Answers:
您可以通过在/ etc / fstab中设置用户名和密码来做到这一点。当然,这样做有一些安全隐患,因为系统上的所有用户都可以看到密码。
例如,添加一行:
//192.168.1.56/share / mnt / share cifs username = robert,password = hunter123 0 0
另请参阅man mount.cifs
,其中记录了一些可用来传递凭据的替代方法。
alias mountc='sudo mount -o credentials=/home/robert/.smbcred'
,并且效果很好。可以用用户名= USER,密码= PASSWORD作为别名,但是我可以更改凭据文件,因为它是由root读取的。
您还可以设置smb.conf文件(/etc/samba/smb.conf)来添加共享sans-authentication。
# /etc/samba/smb.conf file for COMPLETELY INSECURE SHARING
# You need to replace each "USER_NAME" instance with your username
# Apps... Accessories... gedit Text Editor. Search... Replace
[global]
workgroup = WORKGROUP
server string = [HOSTNAME OF YOUR SERVER]
security = share
name resolve order = hosts lmhosts
[SHARE NAME]
path = /path/to/share
force user = [username on server]
force group = [group on server]
read only = no
guest ok = yes
重新启动samba
sudo /etc/init.d/smbd restart
sudo /etc/init.d/nmbd restart
并且共享应该正常显示uo,并且不需要身份验证。
请注意,网络上的每个人都可以查看和访问此共享。