* Remove SSH host keys after installing the custom version of sshd Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com> * 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>
This commit is contained in:
parent
a99debadc1
commit
044570c42e
@ -373,7 +373,8 @@ sudo sed -i 's/LOAD_KEXEC=true/LOAD_KEXEC=false/' $FILESYSTEM_ROOT/etc/default/k
|
||||
## Remove sshd host keys, and will regenerate on first sshd start
|
||||
sudo rm -f $FILESYSTEM_ROOT/etc/ssh/ssh_host_*_key*
|
||||
sudo cp files/sshd/host-ssh-keygen.sh $FILESYSTEM_ROOT/usr/local/bin/
|
||||
sudo cp -f files/sshd/sshd.service $FILESYSTEM_ROOT/lib/systemd/system/ssh.service
|
||||
sudo mkdir $FILESYSTEM_ROOT/etc/systemd/system/ssh.service.d
|
||||
sudo cp files/sshd/override.conf $FILESYSTEM_ROOT/etc/systemd/system/ssh.service.d/override.conf
|
||||
# Config sshd
|
||||
# 1. Set 'UseDNS' to 'no'
|
||||
# 2. Configure sshd to close all SSH connetions after 15 minutes of inactivity
|
||||
|
@ -600,6 +600,11 @@ sudo dpkg --root=$FILESYSTEM_ROOT -P {{ debname }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
# Remove sshd host keys, and will regenerate on first sshd start. This needs to be
|
||||
# done again here because our custom version of sshd is being installed, which
|
||||
# will regenerate the sshd host keys.
|
||||
sudo rm -f $FILESYSTEM_ROOT/etc/ssh/ssh_host_*_key*
|
||||
|
||||
sudo rm -f $FILESYSTEM_ROOT/usr/sbin/policy-rc.d
|
||||
|
||||
# Copy fstrim service and timer file, enable fstrim timer
|
||||
|
4
files/sshd/override.conf
Normal file
4
files/sshd/override.conf
Normal file
@ -0,0 +1,4 @@
|
||||
[Service]
|
||||
ExecStartPre=
|
||||
ExecStartPre=/usr/local/bin/host-ssh-keygen.sh
|
||||
ExecStartPre=/usr/sbin/sshd -t
|
@ -1,18 +0,0 @@
|
||||
[Unit]
|
||||
Description=OpenBSD Secure Shell server
|
||||
After=network.target auditd.service
|
||||
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=-/etc/default/ssh
|
||||
ExecStartPre=-/usr/local/bin/host-ssh-keygen.sh
|
||||
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
RuntimeDirectory=sshd
|
||||
RuntimeDirectoryMode=0755
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Alias=sshd.service
|
Reference in New Issue
Block a user