cours-snt/test-python-ssh/Readme.md
2021-02-11 15:08:34 +01:00

61 lines
1.8 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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.
Also, as this is poorly tested, the docker system make sure the environment is stable.
# Instructions
## Install docker
CF the interweb TODO
## Build the docker image
```
docker build . -t pythonsandbox
```
or pull it
```
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 :
- http://localhost/mod1/func1_1
- http://localhost/mod1/func1_2
- http://localhost/myriem/mod2/func2_1