Add infrastructure to deal with keys

This commit is contained in:
Tristan Andrus 2025-03-27 07:03:06 -06:00
parent 527ca78721
commit e1e8c67e5f
4 changed files with 17 additions and 3 deletions

View File

@ -6,7 +6,9 @@ COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
RUN apt-get update -y && apt-get upgrade -y
RUN apt-get install -y rsync
RUN apt-get install -y rsync ssh
# TODO: Need to install ssh key here
COPY . ./

View File

@ -24,7 +24,12 @@ def requestsync():
try:
# Run rsync
print("Sync requested... running now.")
subprocess.run(['rsync', '-ravzL', REMOTE_DIRECTORY, LOCAL_DEST], check=True)
subprocess.run(['rsync',
'-ravzL',
'-e',
'ssh -i /root/.ssh/id_rsa',
REMOTE_DIRECTORY,
LOCAL_DEST], check=True)
return jsonify({'status': 'OK'})
except subprocess.CalledProcessError as e:
return jsonify({"error": 'rsync failed', 'details': str(e)}), 500

View File

@ -6,7 +6,6 @@ services:
- "35350:35350"
volumes:
- /serve/data/basket:/serve/data/basket
- $HOME/.ssh:/root/.ssh
environment:
- UID=${UID:-1000}
- GID=1000

8
setupkeys.sh Normal file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -u -e -o pipefail
mkdir -p keys
ssh-keygen -f keys/id_rsa -t rsa
ssh-copy-id -i keys/id_rsa sinbad@margarita