title: How to solve 'Cannot authenticate using Kerberos' issue doing EF Core database scaffolding in Linux(Ubuntu 18.04)? Are there any solutions?
body: <p>everyone. I've been trying to develop simple starting AspNetCore application with EntityFrameworkCore to connect and work with MS SQL server database. And manage all this by Rider IDE, tool for Database client(DBeaver) and dotnet command line interface(dotnet ef). I'm using database first approach(create database on mssql server, fill it with tables and then build Models based on tables). My STEP-by-STEP actions:</p>
  
  <p>1)install and set up mssql server for my machine working on Ubuntu 18.04. Install command line tool "SQLCMD". ///
  Link to guide - <a href="https://docs.microsoft.com/en-gb/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-ver15" rel="noreferrer">https://docs.microsoft.com/en-gb/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-ver15</a></p>
  
  <p>2)locally connected to my MSSQLServer instance.
  <strong>sqlcmd -S localhost -U SA -P 'MyPasswd'</strong></p>
  
  <p>3)Using Transact-SQL created Database and install DB client (DBeaver) to fastly manage my databases now and in the future. </p>
  
  <p>Next step, as I supposed, was to use tutorials about connecting my Web Application to database that were found here <a href="https://blog.jetbrains.com/dotnet/2017/08/09/running-entity-framework-core-commands-rider/" rel="noreferrer">https://blog.jetbrains.com/dotnet/2017/08/09/running-entity-framework-core-commands-rider/</a> and here <a href="https://www.entityframeworktutorial.net/efcore/create-model-for-existing-database-in-ef-core.aspx" rel="noreferrer">https://www.entityframeworktutorial.net/efcore/create-model-for-existing-database-in-ef-core.aspx</a></p>
  
  <p>My ASP.NET Core project's package references:</p>
  
  <ul>
  <li>Microsoft.EntityFrameworkCore</li>
  <li>Microsoft.EntityFrameworkCore.SqlServer</li>
  <li>Microsoft.EntityFrameworkCore.Tools</li>
  </ul>
  
  <p>And after typing in CLI command 
  <strong>dotnet ef dbcontext scaffold "Server=localhost;Database=WebAppDB;Integrated Security=true;" Microsoft.EntityFrameworkCore.SqlServer -c RsvpContext</strong> (
  to build "RsvpContext" context to connect to my database WebAppDB.) </p>
  
  <p>I see what I see:</p>
  
  <pre><code>Build started...
  Build succeeded.
  Microsoft.Data.SqlClient.SqlException (0x80131904): **Cannot authenticate using 
  Kerberos. Ensure Kerberos has been initialized on the client with 'kinit' and a 
  Service Principal Name has been registered for the SQL Server to allow Kerberos 
  authentication.**
  
  ErrorCode=InternalError, Exception=Interop+NetSecurityNative+GssApiException: 
  GSSAPI operation failed with error - Unspecified GSS failure.  Minor code may 
  provide more information (SPNEGO cannot find mechanisms to negotiate).
  
  
     at System.Net.Security.NegotiateStreamPal.GssInitSecurityContext(SafeGssContextHandle&amp; context, SafeGssCredHandle credential, Boolean isNtlm, SafeGssNameHandle targetName, GssFlags inFlags, Byte[] buffer, Byte[]&amp; outputBuffer, UInt32&amp; outFlags, Int32&amp; isNtlmUsed)
  
     at System.Net.Security.NegotiateStreamPal.EstablishSecurityContext(SafeFreeNegoCredentials credential, SafeDeleteContext&amp; context, String targetName, ContextFlagsPal inFlags, SecurityBuffer inputBuffer, SecurityBuffer outputBuffer, ContextFlagsPal&amp; outFlags)
  
     at Microsoft.Data.SqlClient.SNI.SNIProxy.GenSspiClientContext(SspiClientContextStatus sspiClientContextStatus, Byte[] receivedBuff, Byte[]&amp; sendBuff, Byte[] serverName)
  
     at Microsoft.Data.SqlClient.SNI.TdsParserStateObjectManaged.GenerateSspiClientContext(Byte[] receivedBuff, UInt32 receivedLength, Byte[]&amp; sendBuff, UInt32&amp; sendLength, Byte[] _sniSpnBuffer)
  
     at Microsoft.Data.SqlClient.TdsParser.SNISSPIData(Byte[] receivedBuff, UInt32 receivedLength, Byte[]&amp; sendBuff, UInt32&amp; sendLength)
  
     at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool, SqlAuthenticationProviderManager sqlAuthProviderManager)
  
     at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
  
     at Microsoft.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
  
     at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
  
     at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
  
     at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal&amp; connection)
  
     at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal&amp; connection)
  
  at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&amp; connection)
  
     at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
  
     at Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
  
     at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
  
     at Microsoft.Data.SqlClient.SqlConnection.Open()
  
     at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(DbConnection connection, DatabaseModelFactoryOptions options)
  
  at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(String connectionString, DatabaseModelFactoryOptions options)
  
     at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions databaseOptions, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
  
     at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
  
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
  
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.&lt;&gt;c__DisplayClass0_0.&lt;.ctor&gt;b__0()
  
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.&lt;&gt;c__DisplayClass3_0`1.&lt;Execute&gt;b__0()
  
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
  ClientConnectionId:38f805bc-5879-458b-9256-d6a201d7ce99
  Cannot authenticate using Kerberos. Ensure Kerberos has been initialized on the 
  client with 'kinit' and a Service Principal Name has been registered for the SQL 
  Server to allow Kerberos authentication.
  ErrorCode=InternalError, Exception=Interop+NetSecurityNative+GssApiException: 
  GSSAPI operation failed with error - Unspecified GSS failure.  Minor code may 
  provide more information (SPNEGO cannot find mechanisms to negotiate).
  
     at System.Net.Security.NegotiateStreamPal.GssInitSecurityContext(SafeGssContextHandle&amp; context, SafeGssCredHandle credential, Boolean isNtlm, SafeGssNameHandle targetName, GssFlags inFlags, Byte[] buffer, Byte[]&amp; outputBuffer, UInt32&amp; outFlags, Int32&amp; isNtlmUsed)
  
     at System.Net.Security.NegotiateStreamPal.EstablishSecurityContext(SafeFreeNegoCredentials credential, SafeDeleteContext&amp; context, String targetName, ContextFlagsPal inFlags, SecurityBuffer inputBuffer, SecurityBuffer outputBuffer, ContextFlagsPal&amp; outFlags)
  
     at Microsoft.Data.SqlClient.SNI.SNIProxy.GenSspiClientContext(SspiClientContextStatus sspiClientContextStatus, Byte[] receivedBuff, Byte[]&amp; sendBuff, Byte[] serverName)
  
     at Microsoft.Data.SqlClient.SNI.TdsParserStateObjectManaged.GenerateSspiClientContext(Byte[] receivedBuff, UInt32 receivedLength, Byte[]&amp; sendBuff, UInt32&amp; sendLength, Byte[] _sniSpnBuffer)
  
     at Microsoft.Data.SqlClient.TdsParser.SNISSPIData(Byte[] receivedBuff, UInt32 receivedLength, Byte[]&amp; sendBuff, UInt32&amp; sendLength)
  </code></pre>
  
  <p>If someone, preferably working on Linux, had the same issue, please let me know and share your solutions(guide on what to do in this situation). </p>