Skip to content

Commit

Permalink
configure ssh for new user
Browse files Browse the repository at this point in the history
  • Loading branch information
mms-gianni committed Oct 11, 2023
1 parent 1038a99 commit 993abe5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packs/fetch/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine:3.18
RUN apk update
RUN apk add git openssh openssh-client
COPY --chmod=0400 ssh_config /etc/ssh/ssh_config
COPY --chmod=0755 ssh_config /etc/ssh/ssh_config
COPY --chmod=0755 init.sh /init.sh

RUN adduser -D -u 1000 kubero
Expand Down
13 changes: 13 additions & 0 deletions packs/fetch/build/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
#ssh-add /root/.ssh/*
#ssh-keyscan github.com >>~/.ssh/known_hosts


# if not root, copy ssh keys and set permissions
if [ ! "$(id -u)" -eq 0 ]; then
echo "========== copy ssh keys"
mkdir -p ~/.ssh
cp -r ~/.ssh-mounted/* ~/.ssh/
chmod -v 700 ~/.ssh
chmod -v 600 ~/.ssh/*
#chmod -v 644 ~/.ssh/*.pub
touch ~/.ssh/known_hosts
chmod -v 644 ~/.ssh/known_hosts
fi

echo "========== whipe the app dir"
rm -rf /app/* /app/.* >> /dev/null 2>&1

Expand Down
7 changes: 4 additions & 3 deletions packs/fetch/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: "3.3"

services:
base-build:
container_name: "base-build"
fetcher:
container_name: "fetcher"
build:
context: ./build
working_dir: /app
Expand All @@ -13,4 +13,5 @@ services:
- GIT_BRANCH=${GIT_BRANCH:-main}
volumes:
- ../../data:/app
- ../../keys/deploykey:/root/.ssh/deploykey
- ../../keys/deploykey:/root/.ssh/deploykey
- ../../keys/deploykey:/home/kubero/.ssh-mounted/deploykey

0 comments on commit 993abe5

Please sign in to comment.