RHEL 7.6挂载Windows CIFS共享目录遇mount error(13): Permission denied问题的排查与配置咨询
RHEL 7.6挂载Windows CIFS共享目录遇mount error(13): Permission denied问题的排查与配置咨询
Hey there, let's work through this permission denied error step by step— I’ve debugged tons of CIFS mount issues on RHEL, so let’s break this down into actionable checks.
First: Verify the Windows Side (Most Common Root Cause)
The "permission denied" error usually starts with Windows permissions or account validity, so let’s rule that out first:
- Test the account directly on Windows: Log into the Windows server with the
papaaccount (or switch users), then try accessing\\localhost\max_stage. If you can’t browse or modify files here, the problem is definitely with the account’s permissions on the share. - Don’t forget dual permissions: Windows uses both share permissions and NTFS folder permissions. Make sure
papahas at least Read access in the share’s permissions, and matching NTFS permissions on the actualmax_stagefolder (right-click the folder → Properties → Security tab). It’s easy to set one and forget the other! - Check if it’s a domain account: If
papais a domain user, you need to specify the domain in your mount command, likeusername=YOUR_DOMAIN\papa— Windows won’t recognize the account without it otherwise. - Use
net usefor precise testing: Open Command Prompt on Windows and run:
Replace Z: with an unused drive letter. If this fails, it’ll give you a specific error code/message (e.g., wrong password, account locked, permission missing) that points directly to the issue. If it works, the account and share are good to go.net use Z: \\localhost\max_stage /user:papa japeto
Next: Troubleshoot the Linux Side
If Windows checks out, let’s fix potential issues on your RHEL 7.6 server:
- Fix your mount command syntax: You’ve got two separate
-oflags— while this sometimes works, it’s better to combine all options into one to avoid parsing issues. Use this instead:mount -t cifs -v //98.12.23.34/max_stage /mnt/target -o vers=2.0,username=papa,pass='japeto' - Check the target directory: Ensure
/mnt/targetis empty, and has proper Linux permissions (runchmod 755 /mnt/targetif needed). This rarely causes permission denied, but it’s a quick check. - Test different SMB versions: Windows servers often have different SMB versions enabled. Try switching to vers=3.0 (more modern) or vers=1.0 (not secure, but useful for testing):
mount -t cifs -v //98.12.23.34/max_stage /mnt/target -o vers=3.0,username=papa,pass='japeto' - Rule out SELinux interference: RHEL’s SELinux can block CIFS mounts by default. Temporarily disable it to test:
If the mount works after this, you’ll need to set a permanent SELinux rule. Run this to allow CIFS access:setenforce 0setsebool -P samba_export_all_rw 1 # Or set the correct context for the target directory chcon -t samba_share_t /mnt/target - Check firewall settings:
- On RHEL: Make sure outbound traffic on port 445 (SMB) is allowed. Temporarily stop firewalld to test:
If it works, add a permanent rule:systemctl stop firewalldfirewall-cmd --add-port=445/tcp --permanent firewall-cmd --reload - On Windows: Ensure the "File and Printer Sharing (SMB)" inbound rule is enabled in Windows Firewall.
- On RHEL: Make sure outbound traffic on port 445 (SMB) is allowed. Temporarily stop firewalld to test:
- Avoid password escape issues: If your password has special characters (like
$,!, or@), using a credentials file is safer than passing it on the command line. Create a file (e.g.,/root/cifs_creds) with:
Then set strict permissions on it:username=papa password=japeto
And mount with:chmod 600 /root/cifs_credsmount -t cifs -v //98.12.23.34/max_stage /mnt/target -o vers=2.0,credentials=/root/cifs_creds
Quick Network Check
Before wrapping up, confirm the Windows server is reachable from RHEL:
- Ping the IP:
ping 98.12.23.34 - Test the SMB port:
telnet 98.12.23.34 445(if this fails, the network or firewall is blocking access)
Start with the Windows-side checks first— that’s where 90% of these issues live. Let me know if any of these steps resolve your problem!
备注:内容来源于stack exchange,提问作者King David
相关产品推荐
相关产品推荐

