CentOS7访问小米路由(Samba服务)


1) 安装samba:yum -y install samba samba-client samba-winbind,查看已安装的samba组件:

rpm -qa | grep samba
samba-common-4.4.4-14.el7_3.noarch
samba-winbind-modules-4.4.4-14.el7_3.x86_64
samba-4.4.4-14.el7_3.x86_64
samba-client-libs-4.4.4-14.el7_3.x86_64
samba-winbind-4.4.4-14.el7_3.x86_64
samba-client-4.4.4-14.el7_3.x86_64
samba-libs-4.4.4-14.el7_3.x86_64
samba-common-libs-4.4.4-14.el7_3.x86_64
samba-common-tools-4.4.4-14.el7_3.x86_64

2) 查询小米路由信息:smbclient -L 192.168.31.1 -U admin%1234,其中admin是小米路由的管理员帐号,1234是密码。(即你平时在浏览器输入miwifi.com显示的登陆页面上输入的帐号密码),我查询的信息出来是这样的:

smbclient -L 192.168.31.1 -U admin%1234567

Sharename Type Comment
--------- ---- -------
XiaoMi-usb0 Disk

从上面可以看到XiaoMi-usb0就是小米路由的共享目录

手动挂载(重启后要重新挂载)
手动挂载小米路由硬盘到CentOS目录:sudo mount -t cifs -l //192.168.31.1/XiaoMi-usb0 /mnt/XiaoMi

mount -t cifs -l //192.168.31.1/XiaoMi-usb0 /mnt/XiaoMi
[sudo] password for cai: 
Password for root@//192.168.31.1/XiaoMi:  ********



就这样,你就可以在CentOS的/mnt/XiaoMi目录看到小米路由的硬盘上的目录和文件了。

自动挂载(开机自动挂载)
1) 创建一个文件,用于存储小米路由的帐号密码:
sudo vi /etc/samba/xiaomi.conf,xiaomi.conf加入帐号密码配置:

username=admin
password=1234



2) 编辑/etc/fstab文件,在最后加入配置:

#
# /etc/fstab
# Created by anaconda on Sun Aug 27 23:39:15 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl_miwifi--r2d--srv-root /                       xfs     defaults        0 0
 
 
//192.168.31.1/XiaoMi                /mnt/XiaoMi             cifs    defaults,credentials=/etc/samba/xiaomi.conf    0    0
//192.168.31.1/XiaoMi-usb0           /mnt/XiaoMi-usb0        cifs    defaults,credentials=/etc/samba/xiaomi.conf    0    0



3) 重新挂载:sudo mount -a

4) 查看挂载:sudo mount,我的显示如下:

//192.168.31.1/XiaoMi on /mnt/XiaoMi type cifs ......
 
//192.168.31.1/XiaoMi-usb0 on /mnt/XiaoMi-usb0 type cifs (rw,relatime,vers=1.0,cache=strict,username=admin,domain=CMI,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.31.1,unix,posixpaths,serverino,mapposix,acl,rsize=1048576,wsize=1048576,echo_interval=60,actimeo=1)



如果出现下面错误:
mount: wrong fs type, bad option, bad superblock on //192.168.31.1/XiaoMi-usb0,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
</type>



运行:
yum install cifs-utils -y


3年前12月15日 阅读:262 评论:0

青锋幽灵

゛. - 看過世间最冷漠滴眼神,  爱過⒈生最无缘滴人﹎

评论 More..

该页面还没有任何评论,赶快占个沙发吧!

登录 注册

您没有登录,如果还不是会员请先注册

文明上网,理性发帖!


顶部