6

Is it possible to connect to Hive via beeline using (kerberos) keytab file similar to the approach used for JDBC at

https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-UsingKerberoswithaPre-AuthenticatedSubject

PS : beeline does support connecting on a kerberos secured hive server with username and password. But I am looking for a way to connect it with a keytab file. http://doc.mapr.com/display/MapR40x/Configuring+Hive+on+a+Secure+Cluster#ConfiguringHiveonaSecureCluster-UsingBeelinewithKerberos

malughanshyam
  • 61
  • 1
  • 1
  • 4
  • The second link, which you've pasted, shows how to do that. Path to keytab file should be passed in the hive-site.xml. Afterwards you connect by command: !connect jdbc:hive2://:10000/default;principal=mapr/, where principal is a principalName present inside your keytab. – greenmarker Jul 06 '15 at 20:53

2 Answers2

8

I think you cannot connect with keytab file into beeline but you can get ticket with keytab using kinit and then pass the hive server principal with the jdbc connection string of beeline to connect.

kinit -k -t keytab principal

Connection string to connect with beeline

!connect jdbc:hive2://hostname:10000/default;principal=hive/_HOST@REALM
Kumar
  • 3,782
  • 4
  • 39
  • 87
  • Kumar and @greenmarker : Thanks for the reply. But even after attempting with the above connection string, it still asks for the _username_ and _password_. Am I missing something ? – malughanshyam Jul 08 '15 at 19:36
  • Just press enter two times. No need to enter any username and password. – Kumar Jul 09 '15 at 03:49
  • only need to change `hostname:port` _HOST@REALM -> this is not a parameter. – sngjuk Jan 25 '22 at 10:27
1

It is a bug, but it is not a critical one.

Though you provided kerberos details, still it will ask you the username and password. You can just enter -> enter, it allows us to connect.

Example:

!connect jdbc:hive2://:10000/default;principal=hive/_HOST@REALM.COM

Connecting to jdbc:hive2://:10000/default;principal=hive/_HOST@REALM.COM

Enter username for jdbc:hive2://:10000/default;principal=hive/_HOST@REALM.COM: press enter

Enter password for jdbc:hive2://:10000/default;principal=hive/_HOST@REALM.COM: press enter

Connected to: Apache Hive (version 0.13.1-cdh5.3.7-SNAPSHOT)
Driver: Hive JDBC (version 0.13.1-cdh5.3.7-SNAPSHOT)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Naga
  • 1,203
  • 11
  • 21