access denied when IOhandler connected but not otherwise?

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
docH
Posts: 59
Joined: Sun 22 Dec 2013 15:18

access denied when IOhandler connected but not otherwise?

Post by docH » Thu 05 Nov 2020 12:58

I am experimenting with a standard TMyConnection, TMyQuery, TMyScIOHandler, TScSSHClient and TSCfileStorage setup, all connected as they should be with TScSSHClient authentication set to atPassword and the correct server credentials set. I assigned a TScSSHClient.HostKeyName and accepted the offer from TSCFilestorage to download a server key.

Whether or not I have TMyConnection.IOHandler property pointing at the TScIOHandler Object, If I toggle the TScSSH client.connected property at design time it allows the connection so the server so the SSH side of things would seem to be OK.

If I delete the TMyConnection.IOHander value, then the TMyConnection and the TMyquery work OK at design time, so the database credentials are set OK

However, when I set the TMyConnection.IOHandler property to be the TScIOHandler Object and then try to open the TMyQuery I get a 'Access denied for <username>@servername (using password :YES)' error.


Strangely, on the same Delphi form I have I followed the same process for a different account and database on the same server and that works OK and gives me a SSH connection to that database.

What could cause the TScSSHclient and TMyConnection to work independently but not when connected together to make a SSH connection?

docH
Posts: 59
Joined: Sun 22 Dec 2013 15:18

Re: access denied when IOhandler connected but not otherwise?

Post by docH » Thu 05 Nov 2020 15:08

Still don't know what the problem was but by duplicating the components and playing with the properties of the file storage and the sshclient it suddenly connected OK. - which doesn't really help as I don't know which property did it.

I suspect it has something to do with the name of the key, the actual filename of the key on the HDD and the FileStorage.KeyExt property especially since after playing for a few days there are many keys in the folder with different extensions. So I'll wait for some replies to my other post here viewtopic.php?f=27&t=42391 that might help to explain which actual key file is being used by the SSHClient and how I know which that is.

I wish the documentation was better instead of that for TSCFileStorage more or less saying
TScFileStorage is used to store information about keys, certificates, and users in files
. but not explaining what all the properties and methods are for. Doing a search for KeyExt returns nothing.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: access denied when IOhandler connected but not otherwise?

Post by ViktorV » Mon 09 Nov 2020 13:46

1. An SSH connection is created when you use set up the TMyConnection.IOHandler property to use the TMySSHIOHandler component. If the property is set to an empty string, a regular TCP connection is established to the server.
2. If you set the TSSHClient.Connected property to True, it will only show whether a connection to the SSH server has been successfully established.
3. As we wrote in the first paragraph, an encrypted SSH connection is established if you set up the TMyConnection.IOHandler property to use the TMySSHIOHandler component. The SSH tunnel serves to transmit your traffic through an SSH connection. A connection to the MySQL server is established from the machine which hosts the SSH server.
4. The 'Access denied for user 'YourUserName'@'YourComputerName'' message is a server response to failed authentication. The message suggests that no user with the 'YourUserName' name exists, an incorrect password has been provided, or such user doesn't have permission to access the server from the 'YourComputerName' machine.
To resolve the issue, you should add grant the necessary privileges to the 'YourUserName' account on the MySQL server. See the MySQL reference for more information: https://dev.mysql.com/doc/refman/8.0/en/grant.html

For example, if you're able to connect to the MySQL server from your machine without using the SSH tunnel, but getting the access denied error when using the same user credentials with an SSH connection, this may suggest that the SSH server is located on a different machine and the user doesn't have the requred privileges to access the server from that machine.

Post Reply