- sshd_started= 0
- try:
- os.stat(sshd_started_flag)
- sshd_started= 1
- except OSError, e:
- pass
-
- if not sshd_started:
- log.write( "Creating ssh host keys\n" )
-
- utils.makedirs( ssh_dir )
- utils.sysexec( "ssh-keygen -t rsa1 -b 1024 -f %s/ssh_host_key -N ''" %
- ssh_dir, log )
- utils.sysexec( "ssh-keygen -t rsa -f %s/ssh_host_rsa_key -N ''" %
- ssh_dir, log )
- utils.sysexec( "ssh-keygen -d -f %s/ssh_host_dsa_key -N ''" %
- ssh_dir, log )
-
- if BOOT_CD_VERSION[0] == 3:
- utils.sysexec( "cp -f %s/sshd_config_v3 %s/sshd_config" %
- (ssh_source_files,ssh_dir), log )
- else:
- utils.sysexec( "cp -f %s/sshd_config_v2 %s/sshd_config" %
- (ssh_source_files,ssh_dir), log )
- else:
- log.write( "ssh host keys already created\n" )
-
+ # create host keys if needed
+ if not os.path.isdir (ssh_dir):
+ utils.makedirs (ssh_dir)
+ key=ssh_dir+"/ssh_host_key"
+ if not os.path.isfile (key):
+ log.write("Creating host rsa1 key %s\n"%key)
+ utils.sysexec( "ssh-keygen -t rsa1 -b 1024 -f %s -N ''" % key, log )
+ key=ssh_dir+"/ssh_host_rsa_key"
+ if not os.path.isfile (key):
+ log.write("Creating host rsa key %s\n"%key)
+ utils.sysexec( "ssh-keygen -t rsa -f %s -N ''" % key, log )
+ key=ssh_dir+"/ssh_host_dsa_key"
+ if not os.path.isfile (key):
+ log.write("Creating host dsa key %s\n"%key)
+ utils.sysexec( "ssh-keygen -d -f %s -N ''" % key, log )
+
+ # (over)write sshd config
+ utils.sysexec( "cp -f %s/sshd_config %s/sshd_config" % (ssh_source_files,ssh_dir), log )
+
+ ### xxx ### xxx ### xxx ### xxx ### xxx