os_kilo_setup.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:solaris-openstack-utils 作者: oracle 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号