The target principal name is incorrect. Cannot generate SSPI context (SPN in cmd prompt showing existing) - sql

We are getting the above error when tried to connect Sql server
The target principal name is incorrect. Cannot generate SSPI context
In SQL error log , I found 2 can't register SPN and Windows 0x2098 error
In cmd prompt when I checked
setspn -l Sql_service_account
It returned 2 records, 1 with FQDN and another one with 1433 port number
Please guide me how to proceed now please.

Related

How to connect to remote SQL Server from WSL2 using ODBC?

I want to connect to a remote SQL Server from WSL2, but I keep getting errors for some reason. I tried connecting using my Windows Host machine without any problem.
~/.odbc.ini
[MSSQLTest]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.9.so.1.1
server=tcp:server,port
Database=Databasename
Trusted_Connection=yes
TrustServerCertificate=yes
uid=username#domain.com
pwd=password
odbcinst -j
unixODBC 2.3.7
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/test/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
Errors
test#Desktop:/mnt/c/Users/test$ isql -v mssqltest
[S1000][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)
[S1000][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Cannot generate SSPI context
I tried several different changes in the DSN, but none worked. The only thing that changed was the error messages. Then I tried installing mssql-tools to use sqlcmd, but I got similar errors.
Errors
test#DESKTOP:/mnt/c/Users/test$ sqlcmd -S server -U domain\\username -P password -G
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish the connection.
I have no idea what the error above means.
test#DESKTOP:/mnt/c/Users/test$ sqlcmd -S server#example.com -U domain\username -P password -G
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
I get a similar error. If I change something in the DSN, I get an error stating No kerberos credentials available (default cache: FIEL:/tmp/krb5cc_1000). Cannot generate SSPI context.
I looked up and tried many different solutions suggested on SO and other sites, but I can't seem to get it working. I can, however, ping the server.
Why is it doing this? Why does my connection work from my Windows Host machine but not WSL? What am I missing?
I don't think there's anything wrong with your setup. You might want to check if your admin allows SQL Authentication. Then use the sqlcmd to check if it works for you. You may be able to figure out the solution then.
sqlcmd -SXX.XX.XX.XXX -U username -P password -Q "select top 5 * from your_table"

TFTP Connect Request Failed

I am trying to setup a TFTP server on Windows Server 2012R2 for a university project, and I am running into an issue when trying to GET or PUT anything on the server.
The command tftp -i 192.168.2.10 put C:\test.txt on the server itself results in
Error on server : ???????????????????? .
Connect request failed
I've made sure both ports UDP 69 and TCP 8099 are open on both inbound and outbound, and I've confirmed that the correct path for the test file is entered, because inserting a typo results in a can't read from local file error.
The ReadFilter value in regedit path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\WDSServer\Providers\WDSTFTP is set to \* and the RootFolder value is set to C:\TFTP which does exist on the server.

'sqlcmd' utility unable to login to the database

I have a large .sql data file (4.3 GB) and I would like to execute this file on SQL Server. Doing some research, I found that I can execute this file using the following command:
sqlcmd -U username -P password -S rs-reporting-v1 -d NSTest -i D:NetSuiteDataFiles\Transactions.sql -o D:\NetSuiteDataFiles\Transactions_output_file.txt
When I execute the above command, get the following error:
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: Could not open a connection to SQL Server [53]. .
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
I've tried changing the username to domain\username but it didn't help at all. I have checked the spellings of username and password multiple times and I'm sure they're correct.
EDIT
I changed my command to the following:
sqlcmd -E -S rs-reporting-v2 -d NSTest -i D:NetSuiteDataFil
es\Transactions.sql -o D:\NetSuiteDataFiles\Transactions_output_file.txt
and now I get the following error:
Would someone please be able to let me know what I'm doing wrong here? Any help would be much appreciated.
I would also like to point out that the .sql file is creating a table and then inserting values.

psql: FATAL: Password authentication failed for user “postgres” WINDOWS

I just installed postgresql 9.0 on my pc.
When it ask for password during install, I entered password.
after install I went to command prompt to import a SQL file.
I use the command psql -f filename.sql. This prompts me for a password to which I enter password.
It then complains that authentication failed for user Morne Nel. I dont exist as a user yet.
I then tried psql -h localhost -U postgres to which I enter the password password.
Only to get this message:
FATAL: Password authentication failed for user "postgres"
What Can I do to resolve this madness?
# Could it be that Jasper Reports server might have something to do with it, is also installs prostgres does iet not?
So is seems that Jasper Reports Server was the culprit here.
Jasper was running on port 5432 and Postgres 9.3 was running on port 5433
I knew that it was on port 5433 from install, but I just assumed that if you try and run command prompt commands that it would use the correct port.
So after uninstalling Jasper Reports Server and changing the port number for Posgres 9.3 in the config file to 5432, I restarted my PC and it worked.

Connect to SQL Server 2016 with always encrypted feature

I am trying to use always encrypted column with SQL Server 2016 and RHEL 7.
I have created my DSN in /etc/odbc.ini.
Info reg odbc.ini is
[test]
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.8.0
Description=My Sample ODBC Database Connection
Trace=Yes
Server=ip address of sqlserver 2016
Database=Test
ColumnEncryption=Enabled
I have tried to put the column master key in .crt format in
/ssl/private and /etc/pki/ca-trust/extracted/pem/.
I am using the command to connect
sqlcmd -D -S test -U test -P test -d Test -Q "select * from empInfo"
I am getting the error
Sqlcmd: Error: Internal error at ReadAndHandleColumnData (Reason: Error reading column data).
SqlState CE200, Keystore provider MSSQL_CERTIFICATE_STORE not found. Ensure that the appropriate Keystore provider library has been loaded.
Can anyone help me with this? It seems like that it is not picking up the certificate. If that is the case then what will be the location of the crt file to put?
Regards,
Sanjay
Currently, MSSQL_CERTIFICATE_STORE is not supported on Linux. You will have to use Azure Key Vault. Please refer this article