Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux &引用;装载错误(126):所需密钥不可用;与CIFS&;Kerberos_Linux_Kerberos_Mount_Cifs - Fatal编程技术网

Linux &引用;装载错误(126):所需密钥不可用;与CIFS&;Kerberos

Linux &引用;装载错误(126):所需密钥不可用;与CIFS&;Kerberos,linux,kerberos,mount,cifs,Linux,Kerberos,Mount,Cifs,我的应用程序需要使用CIFS和Kerberos安全地装载Isilon共享。我的装载尝试返回:所需密钥不可用: mount-t cifs//fileserver.example.com/client123/files /mnt/client123/files-o username=acoder,password=XXXXXX,sec=krb5 答复: mount error(126): Required key not available Refer to the mount.cifs(8) ma

我的应用程序需要使用CIFS和Kerberos安全地装载Isilon共享。我的
装载
尝试返回:
所需密钥不可用

mount-t cifs//fileserver.example.com/client123/files /mnt/client123/files-o username=acoder,password=XXXXXX,sec=krb5

答复:

mount error(126): Required key not available
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
下面是来自
/var/log/messages

Sep 16 16:33:49 clientbox kernel: CIFS VFS: Send error in SessSetup = -126
Sep 16 16:33:49 clientbox kernel: CIFS VFS: cifs_mount failed w/return code = -126
背景和配置

我使用以下方法添加了一个键选项卡:

/usr/bin/ktutil
addent -password -p acoder@EXAMPLE.COM -k 1 -e rc4-hmac
addent -password -p acoder@EXAMPLE.COM -k 1 -e aes256-cts
wkt /etc/krb5.keytab
使用
klist-kte检查

[acoder@clientbox]# klist -kte
Keytab name: FILE:/etc/krb5.keytab
KVNO Timestamp         Principal
---- ----------------- --------------------------------------------------------
   1 09/16/15 16:24:32 acoder@EXAMPLE.COM (arcfour-hmac) 
   1 09/16/15 16:25:46 acoder@EXAMPLE.COM (aes256-cts-hmac-sha1-96) 
下面是
请求key.conf

#OP TYPE    DESCRIPTION CALLOUT INFO    PROGRAM ARG1 ARG2 ARG3 ...
#====== ======= =============== =============== ===============================
create  user        debug:*     negate      /bin/keyctl negate %k 30 %S
create  user        debug:loop:*    *       |/bin/cat
create  user        debug:*     *       /usr/share/keyutils/request-key-debug.sh %k %d %c %S
negate  *       *       *       /bin/keyctl negate %k 30 %S
create  cifs.spnego     *       *       /usr/sbin/cifs.upcall %k
create  dns_resolver    *       *       /usr/sbin/cifs.upcall %k
票证缓存:

# klist | grep "Ticket cache:"
Ticket cache: FILE:/tmp/krb5cc_0
什么可能导致“所需密钥不可用”错误?

编辑: 我在CIFS中启用了调试,并尝试再次装载共享。以下是输出:

fs/cifs/cifsfs.c: Devname: //fileserver.example.com/client123/files flags: 0 
fs/cifs/connect.c: prefix path /files
fs/cifs/connect.c: Username: acoder
fs/cifs/connect.c: file mode: 0x1ed  dir mode: 0x1ed
fs/cifs/connect.c: CIFS VFS: in cifs_mount as Xid: 8 with uid: 0
fs/cifs/connect.c: UNC: \\fileserver.example.com/client123/files ip: 1.2.3.4
fs/cifs/connect.c: Socket created
fs/cifs/connect.c: sndbuf 19800 rcvbuf 87380 rcvtimeo 0x1b58
fs/cifs/connect.c: CIFS VFS: in cifs_get_smb_ses as Xid: 9 with uid: 0
fs/cifs/connect.c: Demultiplex PID: 22937
fs/cifs/connect.c: Existing smb sess not found
fs/cifs/cifssmb.c: secFlags 0x9
fs/cifs/cifssmb.c: Kerberos only mechanism, enable extended security
fs/cifs/transport.c: For smb_command 114
fs/cifs/transport.c: Sending smb: smb_len=78
fs/cifs/connect.c: RFC1002 header 0xbc
fs/cifs/transport.c: cifs_sync_mid_result: cmd=114 mid=1 state=4
fs/cifs/cifssmb.c: Dialect: 2
fs/cifs/asn1.c: OID len = 7 oid = 0x1 0x2 0x348 0x1bb92
fs/cifs/asn1.c: OID len = 6 oid = 0x1 0x3 0x5 0x1
fs/cifs/asn1.c: OID len = 7 oid = 0x1 0x2 0x348 0xbb92
fs/cifs/asn1.c: OID len = 10 oid = 0x1 0x3 0x6 0x1
fs/cifs/asn1.c: Need to call asn1_octets_decode() function for not_defined_in_RFC4178@please_ignore
fs/cifs/cifssmb.c: negprot rc 0
fs/cifs/connect.c: Security Mode: 0x3 Capabilities: 0x8000e2fc TimeAdjust: 0
fs/cifs/sess.c: sess setup type 4
fs/cifs/cifs_spnego.c: key description = ver=0x2;host=fileserver.example.com;ip4=1.2.3.4;sec=krb5;uid=0x0;creduid=0x0;user=acoder;pid=0xXXXXX
fs/cifs/sess.c: ssetup freeing small buf ffff8804359b02701
CIFS VFS: Send error in SessSetup = -126
fs/cifs/connect.c: CIFS VFS: leaving cifs_get_smb_ses (xid = 9) rc = -126
fs/cifs/connect.c: CIFS VFS: leaving cifs_mount (xid = 8) rc = -126
CIFS VFS: cifs_mount failed w/return code = -126

假设您已经发布了
krb5.keytab
中的完整内容,那么它似乎缺少主机的密钥。为了代表用户获得成功的身份验证,服务器需要用户和服务票证。最简单的方法是通过sssd/samba将服务器加入到域中(这将填充您的keytab,然后将用户添加到相同的keytab)

无论如何,有很多方法可以做到这一点,但您必须确保您的keytab(或keytab)具有两个键,以便它可以同时获得两个票据。

“所需键不可用”
表示
cifs.upcall
(由内核运行以响应装载请求)无法获取cifs服务器的Kerberos票证,并由此生成验证服务器所需的密钥(它将进入客户端线程的内核密钥环).
cifs.upcall
记录到
daemon.debug
;首先检查这些消息。通常是
/var/log/daemon
,但您可能需要调整系统日志配置以包含调试级别的消息。在我的系统上,这些消息如下所示:

Aug 19 20:00:26 client.example.com cifs.upcall: [daemon.debug] key description: cifs.spnego;0;0;3f000000;ver=0x2;host=server.example.com;ip4=10.12.0.6;sec=krb5;uid=0x0;creduid=0x2cec;user=res;pid=0x1997
Aug 19 20:00:26 client.example.com cifs.upcall: [daemon.debug] ver=2
Aug 19 20:00:26 client.example.com cifs.upcall: [daemon.debug] host=server.example.com
Aug 19 20:00:26 client.example.com cifs.upcall: [daemon.debug] ip=10.12.0.6
Aug 19 20:00:26 client.example.com cifs.upcall: [daemon.debug] sec=1
Aug 19 20:00:26 client.example.com cifs.upcall: [daemon.debug] uid=0
Aug 19 20:00:26 client.example.com cifs.upcall: [daemon.debug] creduid=11500
Aug 19 20:00:26 client.example.com cifs.upcall: [daemon.debug] user=res
Aug 19 20:00:26 client.example.com cifs.upcall: [daemon.debug] pid=6551
Aug 19 20:00:26 client.example.com cifs.upcall: [daemon.debug] find_krb5_cc: considering /tmp/krb5cc_5601
Aug 19 20:00:26 client.example.com cifs.upcall: [daemon.debug] find_krb5_cc: /tmp/krb5cc_5601 is owned by 5601, not 11500
Aug 19 20:00:26 client.example.com cifs.upcall: [daemon.debug] find_krb5_cc: considering /tmp/krb5cc_5702
...
通常,您会使用如下mount命令:

$ sudo mount -t cifs -o user=acoder,cruid=acoder,sec=krb5 ...
cruid
参数告诉
cifs.upcall
此装载是代表哪个帐户进行的。它将首先查找此帐户(
/tmp/krb5cc.*
)拥有的Kerberos凭据缓存(“ccaches”),以查看该帐户是否已登录并具有当前凭据(例如,如果是一个人,他们已经做了
kinit
);您可以在上面的日志中看到这一点,它正在“考虑”各种ccache。如果失败,它会尝试用一个keytab将其扭结。早期版本只使用系统默认keytab,这意味着客户端主体的密钥必须放在那里(通常是
/etc/krb5.keytab
)。更高版本有一个
-K
标志,可用于为此部署每个用户的keytab,在多用户系统上显然更好。请注意,mount命令中不需要密码;keytab提供了该信息

需要检查的另一件事是,客户端上的Kerberos配置允许获取服务器成功的CIFS票证。例如:

$ kinit acoder@EXAMPLE.COM
... type your password
$ klist
... see your TGT
$ kvno cifs/fileserver.example.com@EXAMPLE.COM
$ klist
... see CIFS ticket
无论如何,有很多变量;从
cifs.upcall
debug日志开始,我们从这里开始


(请注意,第一个答案是混乱和错误的;您应该忽略它。不需要将客户端主机加入域,并且它的主机主体在这里是不相关的。)

在我的例子中,autofs/cifs查找错误的kerberos票证文件名,并给出错误126,因此可能与此有关。它查找的是/tmp/krb5cc_12345678,但实际的kerberos票证文件名在末尾还有7个字符,如下所示:/tmp/krb5cc_12345678_1A23B4请参阅: