def _inject_key_into_fs(key, fs):
 LOG.debug((_('Inject key fs=%(fs)s key=%(key)s') % locals()))
 sshdir = os.path.join('root', '.ssh')
 fs.make_path(sshdir)
 fs.set_ownership(sshdir, 'root', 'root')
 fs.set_permissions(sshdir, 448)
 keyfile = os.path.join(sshdir, 'authorized_keys')
 key_data = ''.join(['\n', '# The following ssh key was injected by Nova', '\n', key.strip(), '\n'])
 _inject_file_into_fs(fs, keyfile, key_data, append=True)
 fs.set_permissions(keyfile, 384)
 _setup_selinux_for_keys(fs, sshdir)

def _inject_key_into_fs ( key , fs ) : LOG . debug ( ( _ ( 'Inject key fs=%(fs)s key=%(key)s' ) % locals ( ) ) ) sshdir = os . path . join ( 'root' , '.ssh' ) fs . make_path ( sshdir ) fs . set_ownership ( sshdir , 'root' , 'root' ) fs . set_permissions ( sshdir , 448 ) keyfile = os . path . join ( sshdir , 'authorized_keys' ) key_data = '' . join ( [ '\n' , '# The following ssh key was injected by Nova' , '\n' , key . strip ( ) , '\n' ] ) _inject_file_into_fs ( fs , keyfile , key_data , append = True ) fs . set_permissions ( keyfile , 384 ) _setup_selinux_for_keys ( fs , sshdir )
add the given public ssh key to roots authorized_keys .