cours-snt/test-python-ssh
2021-02-04 19:11:00 +01:00
..
app python ssh web sandbox, prototype 2021-02-04 19:11:00 +01:00
Dockerfile python ssh web sandbox, prototype 2021-02-04 19:11:00 +01:00
Readme.md python ssh web sandbox, prototype 2021-02-04 19:11:00 +01:00

Python, web and SSH sandbox

For educational purpose. This repo got several parts :

A python script

It run with wsgi, see the dockerfile CMD line). 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

Instructions

Build the docker image

docker build . -t pythonsandbox

Run the docker image

docker run -it --rm -p 8880:80 --name pythonsandbox pythonsandbox

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

docker run -it --rm -p 8880:80 --name pythonsandbox -v "$(pwd)"/app/modules:/usr/share/app/modules pythonsandbox

And with user list file

docker run -it --rm -p 8880:80 --name pythonsandbox -v "$(pwd)"/app/modules:/usr/share/app/modules -v "$(pwd)"/app/users.txt:/usr/share/app/users.txt pythonsandbox

Example

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