CIFS挂载失败并出现错误”mount error(2): No such file or directory”

挂载CIFS共享失败并出现如下错误:

[root@yunweixia.com ~]# mount.cifs -o sec=ntlmssp //smb-server/sambagroup /cifstest/ -vvvv
Password for root@//smb-server/sambagroup:  ******
mount error(2): No such file or directory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)

在内核日志消息(dmesg)中观察到以下错误

[root@yunweixia.com ~]# dmesg -T
[Wed Aug  9 06:00:04 2023] alg: hmac(md5) (hmac(md5-generic)) is disabled due to FIPS
[Wed Aug  9 06:00:04 2023] CIFS: VFS: Could not allocate shash TFM 'hmac(md5)'
[Wed Aug  9 06:00:04 2023] CIFS: VFS: Error -2 during NTLMSSP authentication
[Wed Aug  9 06:00:04 2023] CIFS: VFS: \\smb-server Send error in SessSetup = -2
[Wed Aug  9 06:00:04 2023] CIFS: VFS: cifs_mount failed w/return code = -2
[Wed Aug  9 07:17:33 2023] CIFS: Attempting to mount \\smb-server\sambagroup
[..]

FIPS加密模块状态

[root@yunweixia.com ~]# sysctl -a | grep fips
crypto.fips_enabled = 1
[root@yunweixia.com ~]# cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-5.14.21-150400.24.46-default root=UUID=c3c2cc2a-84f7-4495-9816-f8e2df8155e0 boot=/dev/sda3 USE_BY_UUID_DEVICE_NAMES=1 earlyprintk=ttyS0 console=ttyS0 rootdelay=300 net.ifnames=0 dis_ucode_ldr scsi_mod.use_blk_mq=1 multipath=off fips=1

解决方案

处理该问题有两种选择。第一种可以禁用FIPS,以便CIFS可以使用NTLMSSP安全性。第二种转换为使用Kerberos身份验证,Kerberos身份验证被认为足够安全,可以与FIPS兼容。Kerberos是一项庞大而复杂的工作,因此这里不涉及这些步骤。

禁用FIPS以成功装载CIFS共享

1.临时更改crypto.fips_enabled的sysctl值,您可以使用sysctl命令:

[root@yunweixia.com ~]# sysctl -w crypto.fips_enabled=0

为了使其永久生效,您可以将此行添加到/etc/sysctl.conf或/etc/sysctl.d/目录下的某个文件中:

[root@yunweixia.com ~]# echo 'crypto.fips_enabled = 0' | sudo tee -a /etc/sysctl.d/99-fips.conf

然后,重新加载sysctl配置:

[root@yunweixia.com ~]# sysctl --system

2.修改/etc/default/grub文件

首先,备份原始的/etc/default/grub文件:

[root@yunweixia.com ~]# cp /etc/default/grub /etc/default/grub.bak

编辑grub文件,删除fips=1参数

[root@yunweixia.com ~]# vi /etc/default/grub
# 在文件中找到GRUB_CMDLINE_LINUX_DEFAULT行,并从其值中删除fips=1参数。例如,如果原始行是这样的:
# GRUB_CMDLINE_LINUX_DEFAULT="quiet splash fips=1",修改为如下内容:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

3. 更新GRUB配置

最后,更新GRUB配置以应用更改:

[root@yunweixia.com ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
[root@yunweixia.com ~]# mkinitrd

总结

挂载失败是因为cifs客户端系统上启用了FIPS。NTLMSSP身份验证需要MD5哈希算法,当系统符合FIPS时,该算法将被禁用。换句话说,MD4/MD5的使用未经FIPS批准。因此,禁用FIPS可以使用MD5,随后可以通过NTLMSSP身份验证成功装载CIFS共享

原创文章,作者:运维侠,如若转载,请注明出处:https://www.yunweixia.com/solutions/cifs-mount-error-2-no-such-file-directory-solution.html

(0)
运维侠的头像运维侠共建用户
上一篇 2025年7月28日 18:11
下一篇 2025年7月30日 18:11

相关推荐

发表回复

登录后才能评论