Page 1 of 1

Connection mydac - ssh - mysql

Posted: Mon 27 Nov 2006 23:27
by zvf
Hellow!

First I say sorry for my bad english!!

I need your help, I am going to say what is hapenning...

I need to connect mysql with mydac components, but I need to do it with ssh.

I read the following about mydac components:

MyDAC allows to use such encrypted connections in your applications.
To setup connection with SSH you need:
· Install and configure SSH server such as OpenSSH from
www.openssh.com

· Install SSH client;

· Set connection with port forwarding.
If you use OpenSSH client you should execute following command:
ssh.exe -L 3306::3306 ;
Now your connection to localhost:3306 used by MyDAC is encrypted.
Security Considerations with Port Forwarding

Now, my questions:
1. Ssh client can be putty? Because with putty, I can see my database, but I don´t know how can connect it with delphi or with mydac components.
2. How can I set connection with port forwarding.

Please, I want to learn about it, if you have some internet page, or tutorial, anyone that I can read.

For your help thank you!!!

Posted: Tue 28 Nov 2006 16:35
by Antaeus
> 1. Ssh client can be putty?
It does not matter for MyDAC, what SSH Client is used.

> Because with putty, I can see my database, but I don?t know
> how can connect it with delphi or with mydac components.
To connect to the server, you should set up forwarding with the SSH client and use the port that the SSH client listens to.
For example, your server is run on the 3306 port. Your SSH Client encrypts a data and forwards it from the port number 3000 on the client to the port 3001 on the server. Your SSH Server decrypts the data received from the port number 3001 and forwards it to the port 3306. You should use the port number 3000 on localhost to establish encrypted connection to the server.

> 2. How can I set connection with port forwarding.
This should be described in the documentation of your SSH Client.

Posted: Wed 29 Nov 2006 17:33
by zvf
Hi!!

I can't do it :(

I am doing it:

I have a problem with ports, because I don't know how can put it. I know that ssh connection use port 22, and mysql 3306, but how can I to know the port that need to use my local computer, and how can I to know the port that need to use the server (in the example, you told my that 3000 and 3001, but how can I know what port I need to use?)

Look at it:

I open my ssh client, putty, and I do it for port forwarding:

Host Name (or IP address) : 192.168.5.256
Port : 22

Then I click in Tunnels, and I do it:

Local ports accep connections from other hosts:
Yes or No (I don't know)
Remote ports do the same (SSH-2 only): Yes or No (I don't know)

Add new forwarded port:
Source port: (I don`t know which port)
Destination: (I write here 22, but I think it`s wrong)

Then I click Add and then open.

Then, I write my user and my password,

Then I write the following: mysql -uusuario -p,
then my user and my pasword another one, and I can see my database.


This is with putty, now I open my delphi aplication, with mydac components, in myconnection I write it:

object MiConexion: TMyConnection
Database = 'mibasedatos'
Username = 'usuario'
Password = '*****'
Server = ''
Port = (I don`t know)
end

I run it, but I can't do my connection.

You can help me!!

Thank you very much for your attencion, and excuse my bad english please!!

THANK YOU VERY MUCH!!!!

Posted: Thu 30 Nov 2006 15:54
by Antaeus
> Add new forwarded port:
> Source port: (I don`t know which port)
Any port number on the localhost which will be used to connect with MyDAC (e.g. 3000)

> Destination: (I write here 22, but I think it`s wrong)
Port number on the server which is listed by MySQL Server (default value is 3306)

With these setting the data will be passed in this way:
localhost:3000 server:22 server:3306

Now you should assign correct values to the TMyConnection object:

Code: Select all

object MiConexion: TMyConnection 
  Database = 'mibasedatos' 
  Username = 'usuario' 
  Password = '*****' 
  Server = 'localhost' 
  Port = 3000