Skip to content

Commit ad5dfb9

Browse files
committed
Use an override for for sshd instead of overwriting the service file
Don't overwrite upstream's .service file, and instead use an override file for making sure the host key(s) are generated. Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
1 parent 3489eec commit ad5dfb9

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

build_debian.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ sudo sed -i 's/LOAD_KEXEC=true/LOAD_KEXEC=false/' $FILESYSTEM_ROOT/etc/default/k
407407
## Remove sshd host keys, and will regenerate on first sshd start
408408
sudo rm -f $FILESYSTEM_ROOT/etc/ssh/ssh_host_*_key*
409409
sudo cp files/sshd/host-ssh-keygen.sh $FILESYSTEM_ROOT/usr/local/bin/
410-
sudo cp -f files/sshd/sshd.service $FILESYSTEM_ROOT/lib/systemd/system/ssh.service
410+
sudo mkdir $FILESYSTEM_ROOT/etc/systemd/system/ssh.service.d
411+
sudo cp files/sshd/override.conf $FILESYSTEM_ROOT/etc/systemd/system/ssh.service.d/override.conf
411412
# Config sshd
412413
# 1. Set 'UseDNS' to 'no'
413414
# 2. Configure sshd to close all SSH connetions after 15 minutes of inactivity

files/sshd/override.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[Service]
2+
ExecStartPre=
3+
ExecStartPre=/usr/local/bin/host-ssh-keygen.sh
4+
ExecStartPre=/usr/sbin/sshd -t

files/sshd/sshd.service

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)