In this tutorial you will learn how to connect to a remote MySQL server (on a netcup vServer) through an SSH tunnel. The SSH tunnel allows up to do port-forwarding. In our scenario, we link the database port to us, which means that after the successful connection with the tunnel we access the database server through 127.0.0.1
and not the public IP.
But why should we do that?
Connecting through the SSH tunnel has two advantages:
Both advantages clearly show that we are dealing with security issues here.
We need the following:
A good point. We don't use phpMyAdmin because phpMyAdmin runs on the server and we would have to open a port. This is exactly what we don't want.
After starting HeidiSQL for the first time, you will see a screen similar to the one above, but probably without any entries. In the lower left corner above "new", you can add a new entry.
After creating a new session, you can set the following options on the right side in the "Settings" tab:
MariaDB or MySQL (SSH tunnel)
127.0.0.1
root
or your newly created user3306
Next we go to the 'SSH-tunnel' tab.
In this tab we set the SSH configuration.
plink.exe
3307
(default value)At the bottom left you can now save your changes via "Save".
You can now access your MySQL server through the SSH tunnel without opening any ports.
Copyright (c) 2021 netcup
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
By making a contribution to this project, I certify that:
The contribution was created in whole or in part by me and I have the right to submit it under the license indicated in the file; or
The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same license (unless I am permitted to submit under a different license), as indicated in the file; or
The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the license(s) involved.