Seems like we can if we relax the security settings on the Postgres server.
The server config file can be found via: find $CONDA_DIR -name "postgresql.conf"
To make the postgres server wide open (for initial testing, for example), we can configure it to accept requests from anywhere by adding the following to /srv/conda/srv/pgsql/postgresql.conf. This means changing the default listen_addresses='localhost' (and uncommenting it by removing the leading # if it is commented out) as follows:
# nano $CONDA_DIR/srv/pgsql/postgresql.conf
listen_addresses='*' #Allow all incoming addresses
We also need to add a line to the pg_hba.conf file:
# nano $CONDA_DIR/srv/pgsql/pg_hba.conf
host all all 0.0.0.0/0 md5
The following may do the above from Jupyter terminal?
echo "listen_addresses='*'" >> $CONDA_DIR/srv/pgsql/postgresql.conf
echo "host all all 0.0.0.0/0 md5" >> $CONDA_DIR/srv/pgsql/pg_hba.conf
Or maybe (not sure about the quotes!) something like:
find $CONDA_DIR -name "postgresql.conf" -exec sh -c "echo listen_addresses='*' >> {}" \;
and
find $CONDA_DIR -name "postgresql.conf" -exec sh -c "echo 'host all all 0.0.0.0/0 md5' >> {}" \;
Or perhaps use eg sed to update current/default rules?
After editing files, the docker container will need restarting: docker restart tm351VCE. (Actually, it needs running with an additional port, eg -p 35181:5432 in the original run command, which will mean killing and removing the containing and issuing a new docker run command with the additional port specified, unless we can attach additional ports to the running container or via the restart?).
Using credentials localhost, 35181, user tm351admin and password tm351admin then gives us sight into the database from VS Code:
We should probably look at finding a way to easily tighten security back up to only allow requests coming in from the host IP address, or the student's local netwrok if they are running the TM351VCE as a network server on their home network.
Wondering: can we access the postgres server from VS Code on host using the VS Code postgres extension?
Seems like we can if we relax the security settings on the Postgres server.
The server config file can be found via:
find $CONDA_DIR -name "postgresql.conf"
To make the postgres server wide open (for initial testing, for example), we can configure it to accept requests from anywhere by adding the following to
/srv/conda/srv/pgsql/postgresql.conf
. This means changing the defaultlisten_addresses='localhost'
(and uncommenting it by removing the leading#
if it is commented out) as follows:We also need to add a line to the
pg_hba.conf
file:The following may do the above from Jupyter terminal?
Or maybe (not sure about the quotes!) something like:
find $CONDA_DIR -name "postgresql.conf" -exec sh -c "echo listen_addresses='*' >> {}" \;
andfind $CONDA_DIR -name "postgresql.conf" -exec sh -c "echo 'host all all 0.0.0.0/0 md5' >> {}" \;
Or perhaps use eg
sed
to update current/default rules?After editing files, the docker container will need restarting:
docker restart tm351VCE
. (Actually, it needs running with an additional port, eg-p 35181:5432
in the original run command, which will mean killing and removing the containing and issuing a newdocker run
command with the additional port specified, unless we can attach additional ports to the running container or via the restart?).Using credentials
localhost
,35181
, usertm351admin
and passwordtm351admin
then gives us sight into the database from VS Code:We should probably look at finding a way to easily tighten security back up to only allow requests coming in from the host IP address, or the student's local netwrok if they are running the TM351VCE as a network server on their home network.