How can I programmatically connect to a remote database server that requires an SSH tunnel?

我们两清 提交于 2020-01-01 16:59:09

问题


I'm working on an ETL using C# in which extracts data from a remote MySQL database that requires an SSH tunnel to connect. I currently have it working such that I first create my SSH tunnel manually using PuTTY and then programmaticly connect to the database normally using a MySqlConnection object, etc.

How can I programmatically create the SSH tunnel using C#/.NET? Are there any libraries for doing this and/or is anything built into the .NET framework itself that would aid me in doing this?


回答1:


http://www.example-code.com/csharp/sshTunnel_database.asp




回答2:


  1. Create keys so you don't have to use a password for SSH.
  2. Do the proper SSH command with the proper arguments(for TCP forwarding)(calling an external EXE such as putty)
  3. Use the proper connections settings.
  4. Your done!


来源:https://stackoverflow.com/questions/2064972/how-can-i-programmatically-connect-to-a-remote-database-server-that-requires-an

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!