What I am trying to achieve is to connect my application - that can be used by more than just one person - to host where there is the instance of SQL Server. For security reasons I am using SSH to connect to host itself and within SSH connection I am performing port forwarding so the connection to SQL Server can be made via localhost nad local port. Then the connection to SQL Server is used to perform different SQL queries.
As I said before I can bypass the built-in mechanism to connect to host via SSH and establish port forwarding by using PuTTY (in that case I need only connection to SQL server built in my app). And such solution is workable. I wanted however to incorporate single point where user has to log in rather than start first provide password at start with Pageant, then either start PuTTY or execute Saved Session from Pageant and then to provide login and password to connect to database. The rsa keys that are used to connect to host via SSH can also be used to encrypt the SQL Server user and password so at the end of the day the application user has just to provide the name of the RSA private key and password.
As you can see from the code I have attached. The parts that allows to:
- connect to external host via SSH
- establish the port forwarding connection
- establish connection to SQL Server
are ready and they are working in separation. The problem is to run all of them within single app.
As I said before I can bypass the built-in mechanism to connect to host via SSH and establish port forwarding by using PuTTY (in that case I need only connection to SQL server built in my app). And such solution is workable. I wanted however to incorporate single point where user has to log in rather than start first provide password at start with Pageant, then either start PuTTY or execute Saved Session from Pageant and then to provide login and password to connect to database. The rsa keys that are used to connect to host via SSH can also be used to encrypt the SQL Server user and password so at the end of the day the application user has just to provide the name of the RSA private key and password.
As you can see from the code I have attached. The parts that allows to:
- connect to external host via SSH
- establish the port forwarding connection
- establish connection to SQL Server
are ready and they are working in separation. The problem is to run all of them within single app.