Using Tunneling to connect to iprojsrv
Some of you may want to connect to our SQL Server database on iprojsrv
from your computer at home. However, for security reasons, it is not
possible to directly connect to iprojsrv from outside
the CSE network. All connections must go through a terminal server.
However, it is possible to create a TCP tunnel, which redirects a TCP
connection to a local
port on your computer to a remote IP and port, in this case iprojsrv's
port 1433. The tunnel
can be established as long as you have an SSH connection to one of our
department's linux machines.
For our class, we can use this tunnel in two ways: First, we can
install SQL Server Management Studio (the client program for SQL
Server) locally, connect to iprojsrv through the tunnel, and directly
run SQL queries using a graphical interface. Second, we can write a
Java program which establishes
a JDBC connection to iprojsrv through the tunnel. In this case we do
not need to install SQL Server
locally.
In both cases, we first need to create a tunnel. If you are running
Windows, you can use a GUI SSH client. If you have a Mac or Linux
machine, you can use the command line SSH command.
Using a GUI SSH client
- Start your SSH client. If you don't have an SSH client installed,
you can download Tectia (formerly called SSH Secure Shell) from http://www.washington.edu/uware.
The following instructions are based on Tectia.
- Identify a "connection profile" that is going to be associated
with your tunneling connection to iprojsrv. Here, we will just use
"default-shell" which comes pre-installed with Tectia.
- Go to Edit => SSH Tectia Configuration => Connection
Profiles => default-shell.
- Click the Connection tab. For Hostname, enter
attu.cs.washington.edu. For Username, enter your Linux username. Leave
the other fields unchanged.
- Click the Tunneling tab. Then click the Local Tunnels tab.
- Click the Add button. Choose the following settings:
Type: TCP
Listen Port: 1433
Destination Host: iprojsrv.cs.washington.edu
Destination Port: 1433
- Click OK, and then OK again to exit the Tectia Configuration
window.
- Click on the Profiles button. A drop-down menu will appear. Go to
default-shell and click it.
- Enter your password for attu.cs.washington.edu to establish the
connection.
- Leave the SSH Tectia connection window open. You are now all set.
If connecting from Java code, please read the "Connecting using JDBC"
section below.
Using Command Line SSH
Open a shell and run the following command:
ssh -L 1433:iprojsrv.cs.washington.edu:1433 attu.cs.washington.edu
On windows the above ssh command line client can be replaced with the following
clients (not exhaustive):
-
If you have already installed the SSH Tectia client
UWARE tectia, then in
additional to the GUI client installed, there is also a command line ssh
client installed known as
ssh2.exe. This can be found where tectia is installed, probably under
"C:\Program Files\SSH Tectia\SSH Tectia Client" or
"C:\Program Files (x86)\SSH Tectia\SSH Tectia Client" or perhaps
"C:\Program Files\UWICK\SSH Tectia\SSH Tectia Client". Navigate to this
directory (or make sure it is in your path) and type the above command,
replacing ssh with ssh2.exe. That is:
-
Download putty
and extract/install it to certain directory (assumming the file is authentic).
Then navigate to the installed
directory and type the above command, replacing ssh with putty.exe. That is:
You first need to install SQL Server 2008 locally (note: SQL Server
2005 does not allow you
to connect to SQL Server 2008). You can download an evaluation version
from Microsoft.
You can then start SQL Server Management Studio locally and choose the
following connection
settings:
Server Name: 127.0.0.1
Authentication: SQL Server Authentication
User: YOUR iprojsrv USERNAME
Password: YOUR iprojsrv PASSWORD
Make sure your SSH connection remains open while you are using
Management Studio.
You can also connect to iprojsrv using JDBC. Again, ensure that you
have SSH connection
and set up a tunnel as explained above. In your Java code, you can then
use the following
JDBC connection string
static String connUrl = "jdbc:sqlserver://127.0.0.1:1433;database=imdb;";
You do not need to install SQL Server 2008 on your local machine, if
you are connecting
using JDBC.