简体   繁体   English

为什么 mount.cifs 不使用我的凭证文件?

[英]Why won't mount.cifs use my credential file?

I have a script that needs to mount a Windows share to a Linux box, run a script, then unmount it.我有一个脚本需要将 Windows 共享安装到 Linux 机器上,运行脚本,然后卸载它。 Despite following the man page for mount.cifs the command fails to recognize the credential file.尽管遵循 mount.cifs 的手册页,该命令仍无法识别凭证文件。

I made sure file sharing packages were present:我确保存在文件共享包:

sudo yum install samba-client samba-common cifs-utils

Created drive that network share will mount to创建网络共享将挂载到的驱动器

sudo mkdir /share/

Created the credential file创建凭证文件

sudo vim /root/.cifs

.cifs file contents .cifs 文件内容

username=uname
password=pword

Created my .sh file创建了我的 .sh 文件

sudo vim /usr/bin/scritp.sh

script.sh contents script.sh 内容

#!bin/bash
mount.cifs //ipaddress/share /share/ -o credentials=/root/.cifs
<script which makes use of the share>
umount /share/

Made the script executable使脚本可执行

sudo chmod u+x /usr/bin/script.sh

Tested script测试脚本

cd /usr/bin
sudo ./script.sh

Despite having the credential file specified, I am still prompted for a password for root user (connecting to Windows share with no "root" user" Output from running script:尽管指定了凭据文件,但我仍然提示输入 root 用户的密码(连接到没有“root”用户的 Windows 共享)运行脚本的输出:

Password for root@//ipaddress/share:

Can anyone figure out what I have done wrong?谁能弄清楚我做错了什么? It seems consistent with all documentation I have read.它似乎与我读过的所有文档一致。

For some reason, modifying the script to the following worked:出于某种原因,将脚本修改为以下工作:

mount -t cifs -o credentials=/root/.cifs //ipaddress/share /share/
cd /share/
./script.sh
umount /share/

Not sure why, since mount -t cifs just invokes mount.cifs, but if you are experiencing the same issue, that's how I finally got around it.不知道为什么,因为 mount -t cifs 只是调用 mount.cifs,但如果您遇到同样的问题,我最终就是这样解决的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM