From 9756c9a392179f4b3c1f7732c1c448d116c67a9c Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Fri, 22 Jan 2016 15:53:52 -0800 Subject: [PATCH] vm_clean: delete keys from from /etc/ssh/ before shipping vm It's a bad idea for all Mininet VMs to share the same SSH keys. Certainly users can regenerate their own keys, but it's better if we don't ship a key and simply regenerate it on boot. --- util/install.sh | 14 ++++++++++++++ util/vm/install-mininet-vm.sh | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/util/install.sh b/util/install.sh index 958d49b..8d6d203 100755 --- a/util/install.sh +++ b/util/install.sh @@ -706,6 +706,20 @@ function vm_clean { rm -f ~/.ssh/id_rsa* ~/.ssh/known_hosts sudo rm -f ~/.ssh/authorized_keys* + # Remove SSH keys and regenerate on boot + echo 'Removing SSH keys from /etc/ssh/' + sudo rm -f /etc/ssh/*key* + if ! grep mininet /etc/rc.local >& /dev/null; then + sudo sed -i -e "s/exit 0//" /etc/rc.local + echo ' +# mininet: regenerate ssh keys if we deleted them +if ! stat -t /etc/ssh/*key* >/dev/null 2>&1; then + /usr/sbin/dpkg-reconfigure openssh-server +fi +exit 0 +' | sudo tee -a /etc/rc.local > /dev/null + fi + # Remove Mininet files #sudo rm -f /lib/modules/python2.5/site-packages/mininet* #sudo rm -f /usr/bin/mnexec diff --git a/util/vm/install-mininet-vm.sh b/util/vm/install-mininet-vm.sh index e26ba41..11632ca 100755 --- a/util/vm/install-mininet-vm.sh +++ b/util/vm/install-mininet-vm.sh @@ -43,7 +43,7 @@ fi # Install Mininet time mininet/util/install.sh # Finalize VM -time mininet/util/install.sh -tc +time mininet/util/install.sh -tcd # Ignoring this since NOX classic is deprecated #if ! grep NOX_CORE_DIR .bashrc; then # echo "export NOX_CORE_DIR=~/noxcore/build/src/" >> .bashrc