File size: 1,175 Bytes
a48f0ae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
#!/bin/bash
JUPYTER_PASSWORD="chemCPA"
# Source conda
source /home/user/conda/etc/profile.d/conda.sh
# Activate conda environment
conda activate chemCPA
# Set LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home/user/conda/envs/chemCPA/lib:$LD_LIBRARY_PATH
# Create jupyter config directory if it doesn't exist
mkdir -p ~/.jupyter
# Set up the password
python -c "from jupyter_server.auth import passwd; print(passwd('$JUPYTER_PASSWORD'))" > ~/.jupyter/jupyter_server_password.txt
HASHED_PASSWORD=$(cat ~/.jupyter/jupyter_server_password.txt)
# Create jupyter server config
cat > ~/.jupyter/jupyter_server_config.py << EOF
c.ServerApp.password = '$HASHED_PASSWORD'
c.ServerApp.password_required = True
EOF
chmod 1777 /tmp
chmod 755 /home/user
sudo apt update;
DEBIAN_FRONTEND=noninteractive sudo apt-get install openssh-server -y;
mkdir -p ~/.ssh;
cd $_;
chmod 700 ~/.ssh;
echo "$PUBLIC_KEY" >> authorized_keys;
chmod 700 authorized_keys;
service ssh start;
echo "Starting Jupyter Lab with password authentication"
NOTEBOOK_DIR="/home/user/chemCPA"
jupyter-lab \
--ip 0.0.0.0 \
--port 8888 \
--no-browser \
--allow-root \
--notebook-dir=$NOTEBOOK_DIR
|