Skip to content

Commit 335a0d8

Browse files
committed
Generate new key on every startup.
Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
1 parent 31d65c0 commit 335a0d8

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

build/dockerfiles/dev.sshd.Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ RUN sed -i \
4444
-e 's|#HostKey /etc/ssh/ssh_host_ed25519_key|HostKey /opt/ssh/ssh_host_ed25519_key|' \
4545
/opt/ssh/sshd_config
4646

47-
# Prepare SSH Keys
48-
RUN ssh-keygen -q -N "" -t ed25519 -f /opt/ssh/ssh_client_ed25519_key
49-
RUN chmod 644 /opt/ssh/ssh_client_*
50-
5147
# Add script to start and stop the service
5248
COPY --chown=0:0 /build/scripts/sshd.start /
5349

build/scripts/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const server = http.createServer((req, res) => {
2929

3030
let genKey = "PRIVATE KEY NOT FOUND";
3131
try {
32-
genKey = fs.readFileSync('/opt/ssh/ssh_client_ed25519_key', 'utf8');
32+
genKey = fs.readFileSync(`${process.env["HOME"]}/.ssh/ssh_client_ed25519_key`, 'utf8');
3333
} catch (err) {
3434
// continue
3535
}

build/scripts/sshd.start

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ mkdir -p $HOME/.ssh
1212
if [ -f /etc/ssh/dwo_ssh_key.pub ]; then
1313
cp /etc/ssh/dwo_ssh_key.pub $HOME/.ssh/authorized_keys
1414
else
15-
cp /opt/ssh/ssh_client_ed25519_key.pub $HOME/.ssh/authorized_keys
15+
ssh-keygen -q -N "" -t ed25519 -f $HOME/.ssh/ssh_client_ed25519_key
16+
cp $HOME/.ssh/ssh_client_ed25519_key.pub $HOME/.ssh/authorized_keys
1617
fi
1718

1819
# start

0 commit comments

Comments
 (0)