Kerberos:从密钥表文件 javax.security.auth.login.LoginException 登录失败:无法从用户获取密码<user>

问题描述 投票:0回答:1
我有一个 java 程序,它使用 kerberos keytab 文件来安全地登录到我的 hadoop 服务器。我使用下面的代码来配置所有内容,它在 Eclipse IDE 中工作得很好,但是当我通过 Maven 创建一个可执行 jar 并在命令行上运行时,它不起作用。我看到它能够读取 keytab 文件,但无法检索指定用户 ID 的密码,因此出现错误。有什么建议吗?

Configuration conf = new Configuration(); conf.set("hadoop.security.authentication", "kerberos"); UserGroupInformation.setConfiguration(conf); URL file = this.getClass().getClassLoader().getResource("file.keytab"); UserGroupInformation.loginUserFromKeytab("xyzUser", file.getPath());

我的 keytab 文件保存在根文件夹中,我已将其作为资源标签添加到我的 pom.xml 中。下面是我正在测试我的 jar 文件的命令:

java -jar myjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar
    
java eclipse maven hadoop kerberos
1个回答
0
投票
确保 keytab 文件位于当前目录中,而不是类路径中。

© www.soinside.com 2019 - 2024. All rights reserved.