Local CS131 Server Setup Guide

⚠️ WARNING

This guide assumes a test server creation. The sudo command is used throughout. Do not copy and paste these commands into your own machine, or any server of importance, unless you are sure you know what you are doing (or otherwise prompted).

1 Step 1: Set Up Server to Accept Username/Password

  1. Update and upgrade your system's packages:

    sudo apt update && sudo apt upgrade
  2. Press [Y] or [Enter] when prompted.

  3. Install and enable SSH for remote access:

    sudo apt install openssh-server && \
    sudo systemctl enable ssh && \
    sudo ufw allow ssh
  4. Install the micro text editor:

    sudo snap install micro --classic
  5. Edit SSH configuration to enable username and password authentication:

    sudo micro /etc/ssh/sshd_config
    • Ensure there is no comment sign # before PasswordAuthentication and change PasswordAuthentication from no to yes.
  6. Save changes and restart the SSH service:

    sudo systemctl restart sshd && sudo systemctl daemon-reload

2 Step 2: Install zsh and oh-my-zsh

  1. Install zsh:

    sudo apt install zsh -y
  2. Install curl and git:

    sudo apt install git curl
  3. Install oh-my-zsh:

    sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  4. Follow the prompts, entering your password when required.

3 Step 3: Install Podman

  1. Install Podman:

    sudo apt install podman
  2. Test Podman with a Hello World image:

    podman run hello-world
  3. Create a shared image storage location:

    sudo mkdir /var/lib/shared-images && \
    sudo podman --root /var/lib/shared-images/ pull docker.io/harveymudd/cs131 && \
    sudo podman --root /var/lib/shared-images image ls

4 Step 4: Configure Podman

  1. Create and configure a system-wide storage.conf file:

    sudo micro /etc/containers/storage.conf
    • Paste the appropriate configuration settings to enable image sharing without redownloading.
  2. Update permissions to ensure all users can access the images:

    sudo chmod -R a+rX /var/lib/shared-images/

5 Step 5: Set Up User Templates

  1. Copy the .oh-my-zsh directory and .zshrc configuration file into /etc/skel to set defaults for new users:

    sudo cp -r ~/.oh-my-zsh /etc/skel/.oh-my-zsh && \
    sudo micro ~/.zshrc && \
    sudo cp ~/.zshrc /etc/skel/.zshrc
  2. Initialize configurations:

    source ~/.zshrc

6 Step 6: Create a New User

  1. Create a new user user001 and set a simple password:

    sudo useradd -m -c "Test User 001" -s /bin/zsh user001 && \
    sudo passwd user001
  2. Ensure the user has access to shared images:

    sudo chmod -R a+rX /var/lib/shared-images/

7 Step 7: Login as a CS131 Student

  1. SSH into the server as user001:

    ssh user001@cs131.cs.hmc.edu
  2. Enter the password set earlier.

  3. Launch the CS131 environment using the alias from .zshrc:

    cs131env

8 Step 8: Configure User Memory Limits

  1. Become root and configure memory limits for users:

    su && \
    cd /etc/systemd/system && \
    mkdir -p /etc/systemd/system/user-.slice.d && \
    micro /etc/systemd/system/user-.slice.d/50-memory.conf
  2. Set the memory limit and reload the system daemon:

    systemctl daemon-reload

9 Step 9: Test Memory Limits

  1. Use htop to monitor memory usage and test with resource-intensive commands.