Skip to content

Commit

Permalink
Set host keys to generate on first-boot (vmware-samples#129)
Browse files Browse the repository at this point in the history
Sets host keys to generate on first-boot.
  • Loading branch information
tenthirtyam committed Oct 14, 2021
1 parent 577fbf3 commit 4bfe1f6
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 25 deletions.
2 changes: 1 addition & 1 deletion scripts/linux/photon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ rm -rf /var/tmp/*
# Cleans SSH keys.
echo '> Cleaning SSH keys ...'
#rm -f /etc/ssh/ssh_host_*
rm -f /etc/ssh/ssh_host_*
# Sets hostname to localhost.
echo '> Setting hostname to localhost ...'
Expand Down
4 changes: 0 additions & 4 deletions scripts/linux/rhel7-derivative.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,5 @@ sudo chmod +x /home/$BUILD_USERNAME/clean.sh
echo '> Running the clean script ...'
sudo /home/$BUILD_USERNAME/clean.sh

### Generate the host keys using ssh-keygen. ###
echo '> Generating the host keys using ssh-keygen ...'
sudo ssh-keygen -A

### Done. ###
echo '> Done.'
6 changes: 1 addition & 5 deletions scripts/linux/rhel7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ rm -rf /var/cache/dnf/*
### Clean the SSH keys. ###
echo '> Cleaning the SSH keys ...'
#rm -f /etc/ssh/ssh_host_*
rm -f /etc/ssh/ssh_host_*
### Sets the hostname to localhost. ###
echo '> Setting the hostname to localhost ...'
Expand Down Expand Up @@ -128,9 +128,5 @@ echo '> Running the clean script ...'
sudo /home/$BUILD_USERNAME/clean.sh
### END: Clean the guest operating system. ###

### Generate the host keys using ssh-keygen. ###
echo '> Generating the host keys using ssh-keygen ...'
sudo ssh-keygen -A

### Done. ###
echo '> Done.'
4 changes: 0 additions & 4 deletions scripts/linux/rhel8-derivative.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,5 @@ sudo chmod +x /home/$BUILD_USERNAME/clean.sh
echo '> Running the clean script ...'
sudo /home/$BUILD_USERNAME/clean.sh

### Generate the host keys using ssh-keygen. ###
echo '> Generating the host keys using ssh-keygen ...'
sudo ssh-keygen -A

### Done. ###
echo '> Done.'
6 changes: 1 addition & 5 deletions scripts/linux/rhel8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ rm -rf /var/cache/dnf/*
### Clean the SSH keys. ###
echo '> Cleaning the SSH keys ...'
#rm -f /etc/ssh/ssh_host_*
rm -f /etc/ssh/ssh_host_*
### Sets the hostname to localhost. ###
echo '> Setting the hostname to localhost ...'
Expand Down Expand Up @@ -128,9 +128,5 @@ echo '> Running the clean script ...'
sudo /home/$BUILD_USERNAME/clean.sh
### END: Clean the guest operating system. ###

### Generate the host keys using ssh-keygen. ###
echo '> Generating the host keys using ssh-keygen ...'
sudo ssh-keygen -A

### Done. ###
echo '> Done.'
11 changes: 8 additions & 3 deletions scripts/linux/ubuntu-server-18.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,14 @@ sudo chmod +x /home/$BUILD_USERNAME/clean.sh
echo '> Running the clean script ...'
sudo /home/$BUILD_USERNAME/clean.sh

### Generate the host keys using ssh-keygen. ###
echo '> Generating the host keys using ssh-keygen ...'
sudo ssh-keygen -A
### Set check for ssh keys on reboot; regenerate on reboot if neccessary. ###
echo '> Setting check for ssh keys on reboot; will regenerate on reboot if neccessary. ...'
sudo cat <<EOF > /etc/rc.local
#!/bin/bash
test -f /etc/ssh/ssh_host_dsa_key || dpkg-reconfigure openssh-server
exit 0
EOF
sudo chmod +x /etc/rc.local

### Done. ###
echo '> Done.'
11 changes: 8 additions & 3 deletions scripts/linux/ubuntu-server-2x.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,14 @@ sudo chmod +x /home/$BUILD_USERNAME/clean.sh
echo '> Running the clean script ...'
sudo /home/$BUILD_USERNAME/clean.sh

### Generate the host keys using ssh-keygen. ###
echo '> Generating the host keys using ssh-keygen ...'
sudo ssh-keygen -A
### Set check for ssh keys on reboot; regenerate on reboot if neccessary. ###
echo '> Setting check for ssh keys on reboot; will regenerate on reboot if neccessary. ...'
sudo cat <<EOF > /etc/rc.local
#!/bin/bash
test -f /etc/ssh/ssh_host_dsa_key || dpkg-reconfigure openssh-server
exit 0
EOF
sudo chmod +x /etc/rc.local

### Done. ###
echo '> Done.'

0 comments on commit 4bfe1f6

Please sign in to comment.