def ironic_prep():
"""Prepare ironic user for SSH authentication"""
ironic = pwd.getpwnam("ironic")
print "creating ssh keys"
ironic_pubkey = create_pubkey(ironic)
print "setting .ssh/config"
ssh_config = "Host *\n\tStrictHostKeyChecking no\n"
ssh_config_path = os.path.join(ironic.pw_dir, ".ssh", "config")
with open(ssh_config_path, "w") as fh:
fh.write(ssh_config)
os.chmod(ssh_config_path, 0600)
print "populating authorized_keys"
path = os.path.join(ironic.pw_dir, ".ssh", "authorized_keys")
with open(path, "w") as fh:
fh.write(ironic_pubkey)
owner = "%s:%s" % (ironic.pw_name, grp.getgrgid(ironic.pw_gid).gr_name)
check_call(["chown", "-R", owner,
os.path.join(ironic.pw_dir, ".ssh", "authorized_keys")])
# Configure the Ironic bare-metal service
评论列表
文章目录