Class Related Things

From CS Support
Jump to: navigation, search

Overview

Many of the classes offered in the computer science department require specialized technical knowledge. We've noticed a lot of classes come with their own set of technical questions that students have that can only be answered by our office. As many of the resources that are used in classes require maintenance, our office is in charge of bringing these resources up as well as put security restrictions in place. This is our one stop-shop FAQ-esque section for class related technical questions. This is by no means complete.

CSCI 101 Computers and Applications

With your website you can actually control access to the files with in your directories.

To install htpasswd support on your local system you will need the apache2-utils package installed (in ubuntu).

Using htpasswd

First create the directory you want to control access to. Then create a .htaccess file within the created directory.

Populate the information as you need. A sample is below:

 AuthName "Restricted Area"
 AuthType Basic
 AuthUserFile /web/<designation>/<username>/<directory>/.htpasswd
 AuthGroupFile /dev/null
 require valid-user

Notice it is looking for .htpasswd

To create the .htpasswd file from the command line in linux use the below command:

htpasswd -b -c /web/<designation>/<username>/<directory>/.htpasswd <username to use> <password to encrypt>

The designation is either faculty or students, depending on your role.

CSCI 330 Databases

Our database class studies the theory of database systems through the practice of using MySQL. In this section of the survival guide, we'll walk you through how to access MySQL.

For starters you have to ask yourself how you're going to access MySQL. We require that you access your database through our network for security reasons. So if you plan on accessing it locally (ie, within the departments network, on any lab computer) you can simply run the following line:

mysql -u ${username} -p 

The -u flag indicates the usage of an account username and the -p indicates that a password is associated with your username. If the -p is not specified, mysql will prompt for one.

However if you are planning on working on your databases class anywhere off our network, you need to tunnel through specific port through SSH to access your MySQL database so that when you connect to your database, you're on our network first.

Tunneling MySQL ports through SSH

To connect to the MySQL database, you must connecting from our department network for security reasons. This is easy if you are using the lab machines because your connection is already through our network, but if you're using your own laptop at school or you want to work from home, you will need to Tunnel your traffic from your computer through our network using SSH. SSH Tunneling allows you to securely connect to the Linux COW (linux.cs.wwu.edu) on the department's network in order to send and receive data regarding the MySQL database server through MySQL's port (3306) without having to physically use one of the machines on our network.

After tunneling connection through SSH, you will use the localhost address 127.0.0.1 with port 3306 to connect to the database server because your localhost connection is being tunneled to our network.

Tunneling in Linux/OSX/BSD

In a terminal, enter the following command:

ssh -p 922 -L 3306:mysql.cs.wwu.edu:3306 ${username}@linux.cs.wwu.edu

After entering the command, leave the terminal window open until you are finished with your need for the tunneled connection.

Connecting to the Database Server

You can now use the localhost address 127.0.0.1 with port 3306 to connect to the database server using whichever method your professor specified (e.g. MySQL Workbench).

Tunneling in Windows 10 using a Linux Subsystem (Newer)

Since the Windows 10 Anniversary Update (Version 1603 and later), Microsoft has added the ability to enable the Windows Subsystem for Linux which allows Windows users to run a Bash shell in the Command Prompt or PowerShell. This allows for simple tasks that were not possible prior to the 1603 version update like connecting to another computer with SSH through the Command Prompt!

Once you enable the Windows Subsystem for Linux you will be able to use the same commands you would use in Linux (see above). This guide will walk you through setting the WSL and tunneling the MySQL port on Windows. If you need additional clarification, please consult Microsoft's Documentation on WSL.

  1. Ensure you have Windows 10 Version 1603 or higher by going to Settings > About.
    WindowsVersion1603+.png
  2. Run PowerShell as Administrator and type in the command:
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  3. Follow the on-screen instructions and restart your computer when prompted.
  4. Next you will need to download your linux distribution of choice. You can install that by:
    • Download and install from the Windows Store (please read Microsoft's Documentation for more info)
    • Download and install from the Command-Line/Script (read Microsofts manual instructions here
    • Download and manually unpack and install (for Windows Server, please read Microsoft's Documentation for more info)

Now that you have WSL installed, you can open the Command Prompt or PowerShell and enter bash to open the Bash shell. In this bash shell you can run many native Unix commands like ls, cp, ssh, and many more.

Finally, we are able to run the command like we would in plain old Linux:

ssh -p 922 -L 3306:mysql.cs.wwu.edu:3306 username@linux.cs.wwu.edu

After entering the command, leave the window open until you are finished with your need for the tunneled connection.

Connecting to the Database Server

You can now use the localhost address 127.0.0.1 with port 3306 to connect to the database server using whichever method your professor specified (e.g. MySQL Workbench).

Tunneling with PuTTY in Windows (Older)

PuTTY is a graphical interface for SSH and other such connections in Windows. Before the Windows 10 Fall Creators Update (Version 1803), this was an easy way to use SSH in Windows without jumping through hoops.

The following instructions will show you how to setup an SSH tunnel using Putty, to forward the default port (3306) from your machine through another machine behind a firewall to the MySQL server. This allows you to connect to the remote server's MySQL database as if it were running on your local box, and will traverse any firewalls that block port 3306, but allow port 922.

Setting up the tunnel configuration

PuttyConfig1.png

Run PuTTY

  1. Under category expand Connection
  2. Expand SSH
  3. Select Tunnels
  4. Select Source port and enter 3306
  5. Select Destination and enter mysql.cs.wwu.edu:3306
  6. Make sure the Local and Auto radio buttons are selected
  7. Select Add

Saving the Session

PuttyConfig2.png
  1. Under category selectSession
  2. Under Host Name (or IP address), enter ${username}@linux.cs.wwu.edu. Make sure you replace ${username} with your username
  3. Under Port, enter 922
  4. Under Saved Sessions, enter a name
  5. Select Save
  6. Select Open to connect to the server

Connecting to the Database Server

You can now use the localhost address 127.0.0.1 with port 3306 to connect to the database server using whichever method your professor specified (e.g. MySQL Workbench).