X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2Fsteps%2FStartDebug.py;h=f913dc800eadd3bc6227c486ddf83bb0a6a71664;hb=f34ef1af6e4ba70e19c943ac3ef388675998b3f8;hp=fc403e6c7e1d06ada46caa02acdb0eed18651ee7;hpb=d4be39e78e9a1a0c1885958e74189280a281be1b;p=bootmanager.git diff --git a/source/steps/StartDebug.py b/source/steps/StartDebug.py index fc403e6..f913dc8 100644 --- a/source/steps/StartDebug.py +++ b/source/steps/StartDebug.py @@ -83,19 +83,26 @@ def Run(vars, log, last_resort = True): utils.makedirs (ssh_dir) # original code used to specify -b 1024 for the rsa1 key + # fedora23 seems to come with a release of openssh that lacks suppport + # for ssh1, and thus rsa1 keys; so we consider that failing to produce + # the rsa1 key is not a showstopper key_specs = [ - ("/etc/ssh/ssh_host_key", 'rsa1', "SSH1 RSA"), - ("/etc/ssh/ssh_host_rsa_key", 'rsa', "SSH2 RSA"), - ("/etc/ssh/ssh_host_dsa_key", 'dsa', "SSH2 DSA"), + ("/etc/ssh/ssh_host_key", 'rsa1', "SSH1 RSA", False), + ("/etc/ssh/ssh_host_rsa_key", 'rsa', "SSH2 RSA", True), + ("/etc/ssh/ssh_host_dsa_key", 'dsa', "SSH2 DSA", True), ] - for key_file, key_type, label in key_specs: + for key_file, key_type, label, mandatory in key_specs: if not os.path.exists(key_file): log.write("Creating {} host key {}\n".format(label, key_file)) - utils.sysexec("{} -q -t {} -f {} -C '' -N ''"\ - .format(key_gen_prog, key_type, key_file), log) - utils.sysexec("chmod 600 {}".format(key_file), log) - utils.sysexec("chmod 644 {}.pub".format(key_file), log) + if mandatory: + run = utils.sysexec + else: + run = utils.sysexec_noerr + run("{} -q -t {} -f {} -C '' -N ''"\ + .format(key_gen_prog, key_type, key_file), log) + run("chmod 600 {}".format(key_file), log) + run("chmod 644 {}.pub".format(key_file), log) # (over)write sshd config utils.sysexec("cp -f {}/sshd_config {}/sshd_config".format(ssh_source_files, ssh_dir), log) @@ -113,7 +120,8 @@ def Run(vars, log, last_resort = True): # start sshd if not os.path.isfile(sshd_started_flag): log.write("Starting sshd\n") - utils.sysexec("service sshd start", log) + utils.sysexec("service sshd start || systemctl start sshd", + log, shell=True) # flag that ssh is running utils.sysexec("touch {}".format(sshd_started_flag), log) else: