diff --git a/src/mkvm/configure.py b/src/mkvm/configure.py index c52cd69..58ee8a5 100644 --- a/src/mkvm/configure.py +++ b/src/mkvm/configure.py @@ -75,6 +75,16 @@ def enable_console_login(mountpoint, driver): f.write(line) +def enable_sshd(mountpoint): + cmd = ['chroot', mountpoint, 'ssh-keygen', '-A'] + output = subprocess.check_output(cmd) + if output: + log.info(output.decode().strip()) + path = os.path.join(mountpoint, 'etc/runlevels/default/sshd') + if not os.path.exists(path): + os.symlink('/etc/init.d/sshd', path) + + def run_custom_script(mountpoint, script): cmd = ['chroot', mountpoint, '/bin/sh'] env = CUSTOM_SCRIPT_ENV.copy() @@ -98,6 +108,8 @@ def configure(vm): set_hostname(vm.mountpoint, vm.fqdn) if vm.console: enable_console_login(vm.mountpoint, vm.console) + if vm.net_ifaces: + enable_sshd(vm.mountpoint) if vm.customize: run_custom_script(vm.mountpoint, vm.customize)