This assignment is my Server-Side Web Application Development class and using C# base

YELLOWFISH24
SSHTunnelingTutorial3.docx

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.

*** TIP: If your database connection is working and suddenly stops, check the PuTTY window. Often times the tunnel will have disconnected for one reason or another, and starting it again is all that is required to fix the issue. Visual Studio Change: You will need to use a different way to access the database server when you plan to work from home. The method described above will allow you to connect to Temple’s network, but you will not be able to access the cis-mssql1 server the same was as when working from school (as described in the Account & Project Setup VS2012 document located under the Course Documents section of Blackboard). From Visual Studio, go to the View menu, and select SQL Server Object Explorer to display the tool window. Then, click the Add SQL Server icon at the top of the SQL Server Object Explorer window.