Introduction
This lab will help you set up your developmental workspace for this class. We will making use of the DETER testbed, a computing facility for cyber-security research and development. On DETER, we will be able to run network security experiments without the risk of breaking out into the real world.
In this course, we will be developing network security applications, which comes with the unfortunate side effect that you will develop on your own machine, but test and execute things on one or more remote machines. Therefore, get ready to be comfortable with a command prompt, or actually a bunch of them open at the same time. In what follows, I will describe one possible developmental setup that you can use, but feel free to use whatever works best for you at the end.
Step 1: Install WSL2 and Ubuntu-20.04 (or any other distro)
I assume that by this point in time in your studies, you are familiar with the Windows Subsystem for Linux 2 (WSL2) and you have a working Linux shell on your Windows machine. If you are not using a Windows machine, then you can skip over this section and use any terminal emulator of your liking.
If you do not have WSL2 installed, then please follow the instructions in this post and make sure you have access to a Linux terminal window. You do not have to install Ubuntu, you can install any distribution of your liking (Kali Linux is a good one for penetration testing) as long as you know how to use it and you are comfortable installing software and using the shell.
Step 2: Install prerequisite software
Next, let’s install a bunch of software that we are going to need for this class. On your Unix/Linux terminal, run the following command:
sudo apt install -y git build-essential tmux
Note: Replace apt
with your favorite package manager if you know what that is.
Step 3: Generate ssh keys
If you have already generated SSH keys for your Linux machine (i.e., from the Linux terminal and not from GitBash), you can skip this step.
Open your Linux terminal, and issue the following command:
ssh-keygen -b 4096 -t rsa
- Accept the default install location (
~/.ssh/id_rsa.pub
) - I generally do not use a passphrase for my SSH keys, but feel free to use one if you so desire.
- Verify that your keys have been generated by reading your public key using
cat ~/.ssh/id_rsa.pub
You should see a bunch of nonsense printed on the screen that is starting with
ssh-rsa
. Copy the generated line (you will probably have to right click and copy from the terminal, as Ctrl-c is reserved on Linux terminals).
Step 4: Add the SSH keys to your GitHub account
If you have already generated your SSH keys from your Linux terminal and added those to your GitHub account, then you can skip this step. Otherwise, follow the steps in this tutorial to add the generated SSH key to your GitHub account. This will allow for password-less access to your repositories.
Step 5: Create a private repository on GitHub
Create a private repository on GitHub that you will be using to develop the labs
in this course. Name the repository something catchy, like sexy-daemon
or
whatever you like. Choose python
as the default language (so that you get the
right .gitignore
file) and then check the box that creates a README
file in
your repository.
In your Linux terminal, clone the repository using
git clone <ssh_url_to_your_repo_here>
and then navigate to the cloned folder using cd
. From there, open an instance
of Virtual Studio Code using
code .
This will launch an instance of VSCode that is configured to run from your class repository. This will be where you will develop code for the most part in this class. We will be mainly using Python but we will also use C on occasions.
Step 6: Create your DETER account and add your keys to it
At this point, you should have received an email from the DETER testbed that gives you your username and a link to set your password. Make sure to fill out all the information on the DETER sign up page since we will need that information in case we need to perform some troubleshooting for your account.
Next, let’s open up the directory where your public key (id_rsa.pub
) is. Using
your Linux terminal (on WSL2), issue the following command
cd ~/.ssh/
and then do
explorer.exe .
Note that this only works if you are using WSL2 on a Windows machine, if you are on MacOS, then you can use
open .
You will end up with a file explorer window that points to your local .ssh
directory. In that directory, you will find two files: id_rsa
and
id_rsa.pub
. We are interested in the public key (i.e., id_rsa.pub
) as
the private key must remain secret and should never be shared with anyone else.
Copy the id_rsa.pub
file to your Desktop and move on to the next step below.
Sign in to DETER with your updated account at this
link and then navigate to the Profile
tab under the welcome page. On the left hand side, you will see an Options
menu with an entry for Edit SSH Keys
. Using the Browse
button, navigate to
your Desktop and select the id_rsa.pub
file that we have just copied to the
Desktop. Enter your password and click on Add New Keys
. If all goes well, you
should see your public key appear in the text box at the top of the page.
Step 7: Test your DETER connection
To test your access to DETER, let’s try to ssh
into the users server on the
testbed, from your Linux shell
ssh <username>@users.deterlab.net
where <username>
is the username assigned to you from the DETER email you
received. If all goes well, you should be able to log in to the server and have
a shell to run your commands.
Setting ssh config file
To save you the trouble of typing the full URL when logging into DETER, let’s
create a ssh
configuration file. From you Linux terminal, issue the following
command
touch ~/.ssh/config
and then using your favorite editor (you can use code ~/.ssh/config
to use
VSCode), edit the file to look something like the following:
Host deter
HostName users.deterlab.net
User <place_your_deter_username_here>
Save the file and then from your terminal, try to login to DETER again, but this time using only
ssh deter
You should be able to login now and use the DETER testbed for your experiments in this class.