This assignment is my Server-Side Web Application Development class and using C# base
Connecting to Temple Database Server from Home
In order for your code to connect to the database servers at Temple when you are not on campus, SSH tunneling must be used. This document illustrates the exact process for setting up tunneling using the PuTTY program, which can be downloaded from http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe. There are many ways to accomplish this, but this method is simple to setup
To begin, open PuTTY and navigate on the left-hand side to Connection -> SSH -> Tunnels as is shown in the image below. Enter cis-mssql1.temple.edu:1433 as the destination and enter 5555 as the source port (could use any port, but the setup in this document will use port 5555). Once your window looks like the image below, click Add and you will see the server destination and source port listed under “Forwarded ports”.
After the tunnel information has been added, click on the Session category at the top of left-hand side (as seen below) in order to get back to the default configuration page. All you need to add here is the Host Name, which is “tuxXXXXX@cis-linux2.temple.edu”, substituting your AccessNet information for the X’s.
(Optional) You can type a name under “Saved Sessions” and then click “Save” after the configuration is complete to store the settings. In the future when you load PuTTY you will simply click on the appropriate saved session and then “Load” to automatically load all of your settings, if using this method.
Once everything is set up properly, simply click on the “Open” button at the bottom of the screen and a command line window will be opened.
You will be presented with the prompt below, where you must enter your AccessNet password and then press the “Enter” key in order to continue.
If you see the screen below after answering your password, that’s it! The SSH tunnel is now set up. PLEASE NOTE: You do not need to type anything in the command line, but you MUST leave this window open for as long as you require use of the tunnel.
Now that the tunnel is running, all that needs to be done is changing your connection string in Visual Studio so that your application connects to the database server correctly. Anywhere that a connection string is used, whether in your Connection.vb or in a GridView control or anywhere else, you must make the following change from (as an example):
string SqlConnectString = "server=cis-mssql1.temple.edu;Database=FA14_3342_tuxXXXXX;User id=tuxXXXXX;Password=xxxxxx”;
to:
string SqlConnectString = "server=127.0.0.1,5555;Database=FA14_3342_tuxXXXXX;User id=tuxXXXXX;Password=xxxxxx”;
To clarify: Yes, that is a comma between 127.0.0.1 and 5555. This was the way that I was initially able to get my database connection to work, but it is likely you may be able to use the name “localhost” instead of 127.0.0.1 since they both refer to the same thing.
*** IMPORTANT: Be sure that before you publish your Web page, you change ALL of the connection strings back to their original form (e.g. server=cis.msssql1.temple.edu) or your site will not work properly.