wiki:Labs01
Last modified 5 years ago Last modified on 02/01/13 14:02:38

Lab 01: Fixing Today's Class

Goals:

Getting SSH keys installed

A complete ssh key setup should look like this

$ ls ~/.ssh

authorized_keys
config
id_rsa
id_rsa.pub

I'm missing id_rsa or id_rsa.pub

You need to generate a keypair. Accept the default file, and use a passphrase

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.

I'm missing authorized_keys

Once you have generated your key pair, copy or append your public key to your authorized_keys file

$ cd ~/.ssh
$ cat id_rsa.pub >> authorized_keys

I'm missing config

Edit ~/.ssh/config and add the following contents

Host swat
  HostName lab.cs.swarthmore.edu
  User swatuser

Host gitrepos
  HostName git.cs.swarthmore.edu
  User gituser

Host *
  ForwardX11 yes
  ForwardAgent yes
  
HashKnownHosts yes

Replace swatuser with your Swarthmore CS user name.

Testing your ssh setup

run ssh-add and enter your ssh key passphrase to add your key to the ssh agent. If you get an error saying no agent is running, type

ssh-agent bash

and try ssh-add again. If it works you should see the following output

Enter passphrase for /home/swatuser/.ssh/id_rsa: 
Identity added: /home/swatuser/.ssh/id_rsa (/home/swatuser/.ssh/id_rsa)

Again, swatuser will be replaced with your Swarthmore CS user name

try connecting to a remote host, e.g., lime. You should not be prompted for a password. If you are, we need to fix your configuration.

If everything looks OK, but still isn't working, there may be permission problems with your authorized_keys or config. Try the following

cd ~/.ssh
chmod 600 authorized_keys config

Give me your public key

run update40 and cd ~/cs40/pubkey to move to the pubkey folder. Copy your id_rsa.pub file here

cp ~/.ssh/id_rsa.pub ~/cs40/pubkey

Things should look like this

onion[pubkey]$ pwd
/home/adas/cs40/pubkey

onion[pubkey]$ ls
id_rsa.pub

All good? Now run handin40 to send me your public key.

Run git clone

Before you can continue with the next step, I must run a script to grant your public key access to the cs40 code. Once you have the go ahead from me, try

$ cd ~/cs40

$ git clone gitrepos:cs40s13 code
Cloning into 'code'...
X11 forwarding request failed on channel 0
remote: Counting objects: 81, done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 81 (delta 13), reused 0 (delta 0)
Receiving objects: 100% (81/81), 612.89 KiB, done.
Resolving deltas: 100% (13/13), done.

$ ls 
code/  pubkey/

If you are asked for a password, either your ssh keys are not set up properly, you have not run ssh-add, I have not added your key to the allowed user, or _OTHER_.

Once you have a code directory, things are looking good and you shouldn't have too many problems

Build the sample code

Move into your code directory and list your branches

cd ~/cs40/code

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

If you do not see a working branch, create one using

$ git checkout -b working
Switched to a new branch 'working'

$ git branch -a
  master
* working
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

The * indicates your current branch. More about branches later, but basically, Do not edit code while in the master branch

If you do not have a build directory, create one using

cd ~/cs40/code
mkdir build

cd into your build directory and run cmake

cd build
cmake ..
make -j8

If cmake complains about not finding GLEW, let me know. Jeff or I will need to install libglew1.6-dev on your machine.

If all goes well, you should be able to run the following programs

[build]$ ./w01-intro/simpletests/helloCS40 
Hello CS40!

[build]$ ./w01-intro/simpletests/mathTest1
Cos(0)= 1

[build]$ ./w01-intro/simpletests/mathTest2
Sin(pi)= 1.22465e-16

[build]$ cd w01-intro/pngtest/
[pngtest]$ ./test_rgb 
caught exception: Column index 700 out of bounds
Opening campus.png
Img2 (rows, cols)= 716  927
Saving campus.png to saved.png

[pngtest]$ cd ../Chapter02/

[Chapter02]$ ./example1

(shows a crazy triangle thing)

[Chapter02]$ cd ../qtTestOGL/
[qtTestOGL]$ ./ogltest

(shows an interactive triangle thing)