#NEWLINE# @ classmethod #NEWLINE# def merge_authorized_keys( cls , host , keyname , user , is_verbose ) : #NEWLINE# #INDENT# " Adds the contents of the user's authorized_keys file to the root's\n    authorized_keys file.\n\n    Args:\n      host: A str representing the host to enable root logins on.\n      keyname: A str representing the name of the SSH keypair to login with.\n      user: A str representing the name of the user to login as.\n      is_verbose: A bool indicating if we should print the command we execute to\n        enable root login to stdout.\n    " #NEWLINE# AppScaleLogger . log ( 'Root login not enabled - enabling it now.' ) #NEWLINE# create_root_keys = 'sudo touch /root/.ssh/authorized_keys' #NEWLINE# cls . ssh ( host , keyname , create_root_keys , is_verbose , user = user ) #NEWLINE# set_permissions = 'sudo chmod 600 /root/.ssh/authorized_keys' #NEWLINE# cls . ssh ( host , keyname , set_permissions , is_verbose , user = user ) #NEWLINE# temp_file = cls . ssh ( host , keyname , 'mktemp' , is_verbose , user = user ) #NEWLINE# merge_to_tempfile = 'sudo sort -u ~/.ssh/authorized_keys /root/.ssh/authorized_keys -o {}' . format ( temp_file ) #NEWLINE# cls . ssh ( host , keyname , merge_to_tempfile , is_verbose , user = user ) #NEWLINE# overwrite_root_keys = "sudo sed -n '/.*Please login/d; w/root/.ssh/authorized_keys' {}" . format ( temp_file ) #NEWLINE# cls . ssh ( host , keyname , overwrite_root_keys , is_verbose , user = user ) #NEWLINE# remove_tempfile = 'rm -f {0}' . format ( temp_file ) #NEWLINE# cls . ssh ( host , keyname , remove_tempfile , is_verbose , user = user ) #NEWLINE# return