Skip to content

Latest commit

 

History

History
138 lines (105 loc) · 3.43 KB

README.org

File metadata and controls

138 lines (105 loc) · 3.43 KB

Readme

Table of Contents

Intro to Bash and Linux

Practical consists of 100 users (user1 - user100) on a docker container.

For each user

  • have file ~/fruit.txt
  • a couple dummy files in ~/tree
  • have file rename.txt with a groceries todo list inside of it

Globally

  • Have grep installed

Setup script

mkdir /run/sshd
# Make sure script doesn't run twice
if ! grep -q user80 "/etc/passwd"; then
    # Create users
    for num in $(seq 1 80)
    do
        password=$(echo 'SESH_LINUX' | openssl passwd -6 -stdin)
        username=user$num
        useradd -m -s /bin/bash $username --password $password
        echo "Good job finding this hidden file!" > /home/$username/.hidden.txt
        echo "Tomatoes" > /home/$username/fruit.txt
        echo "- Grapes\n- Oranges\n- Peaches" > /home/$username/rename.txt
        sudo chown $username:$username /home/$username/rename.txt
        sudo chown $username:$username /home/$username/.hidden.txt
        sudo chown $username:$username /home/$username/fruit.txt
        mkdir /home/$username/tree
        echo "Just a leaf" > /home/$username/tree/leaf.txt
        sudo chown $username:$username /home/$username/tree
        sudo chown $username:$username /home/$username/tree/leaf.txt
        echo "high permissions" > /home/$username/perms.txt
    done
fi

SSHD config

Include /etc/ssh/sshd_config.d/*.conf
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem       sftp    /usr/lib/openssh/sftp-server
PasswordAuthentication yes
Port 2222

Dockerfile

FROM ubuntu:latest

RUN apt update

RUN DEBIAN_FRONTEND=noninteractive apt install ubuntu-minimal ubuntu-standard vim openssl openssh-server -y

COPY sshd_config /etc/ssh/sshd_config

EXPOSE 2222

RUN mkdir /run/sshd

COPY init.sh /init.sh
COPY entrypoint.sh /entrypoint.sh

RUN chmod +x /init.sh
RUN chmod +x /entrypoint.sh
RUN /init.sh

ENTRYPOINT ["/entrypoint.sh"]

keep container alive

/usr/sbin/sshd -D
while true; do sleep 1; done

docker-compose

version: '3'

services:
  container:
    image: sesh_bash_linux
    build:
      context: .
      dockerfile: ./Dockerfile
    ports:
      - "2222:2222"

Makefile

Makefile to make our lives easier

default: help

build: ## Build image from scratch
		@docker-compose build --no-cache

run: ## Run docker compose
		@docker compose up --build

up: ## Run docker compose in daemon mode
		@docker compose up -d --build

down: ## Shut down the running docker daemon and delete its volumes
		@docker compose down -v

help: ## Display this help message
		@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf "  \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)