cours-snt/test-python-ssh
2021-02-05 17:11:47 +01:00
..
nginx organisation 2021-02-05 17:11:47 +01:00
python_app organisation 2021-02-05 17:11:47 +01:00
sshd organisation 2021-02-05 17:11:47 +01:00
Dockerfile organisation 2021-02-05 17:11:47 +01:00
entrypoint.sh organisation 2021-02-05 17:11:47 +01:00
Readme.md organisation 2021-02-05 17:11:47 +01:00

Python, web and SSH sandbox

For educational purpose only! None of this software is industry grade quality.

This repo got several parts :

A python script

It run with uwsgi, see the dockerfile CMD line. You will need to change it to make it listen on a port. Used to execute any python script in the module directory given a certain URL :

  • /m1/f1 -> execute the f1 function from modules/m1.py
  • /path/to/m2/f2 -> execute the f2 function from modules/path/to/m2.py

SSH server

Allow student to connect via SSH or SFTP to add python files. create a file named users.txt, then passwords and accounts will be generated by entrypoint.sh TODO:

  • install and configure the server
  • configure chroot
  • create the homes in modules directory

A docker image

To bundle everything in one place. This docker image is not a pretty one, we should split those services into several containers. But that would be harder to run, so forget that.

Instructions

Install docker

CF the interweb TODO

Build the docker image

docker build . -t pythonsandbox

or pull the image

TODO: send image to hub

Run the docker image

docker run -it --network host --name pythonsandbox pythonsandbox

Or if you want to save student work outside of the container:

docker run -it --network host --name pythonsandbox -v "$(pwd)"/app/modules:/usr/share/app/modules pythonsandbox

And with user list file

docker run -it --network host --name pythonsandbox -v "$(pwd)"/app/modules:/usr/share/app/modules -v "$(pwd)"/app/users.txt:/usr/share/app/users.txt pythonsandbox

Roadmap

Example

With the files under ./app/modules you can get the following URLs :