Exemple #1
0
function push_authorized_key_file($identity_name, $account_name, $host, $file)
{
    $output = array();
    $command = "scp -v -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /tmp/{$identity_name}-id /tmp/authorized_keys {$identity_name}@{$host}:~ 2>&1";
    exec($command, $output, $exit_status);
    display_command_output("Push new authorized key file to {$host}", $exit_status, $output, $command, "error");
    $command = "ssh -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /tmp/{$identity_name}-id {$identity_name}@{$host} \"sudo cp ~/authorized_keys {$file};sudo chown {$account_name} {$file};sudo chmod 600 {$file}\" ";
    exec($command, $output, $exit_status);
    display_command_output("Replace on {$host} authorized key file with new one", $exit_status, $output, $command, "error");
}
Exemple #2
0
function test_connection($host, $identity_name, $account_name)
{
    $output = array();
    $command = "ssh -vvv -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /tmp/{$identity_name}-id {$identity_name}@{$host} \"ls -l\" 2>&1";
    exec($command, $output, $exit_status);
    display_command_output("Test connection", $exit_status, $output, $command, error);
    return $exit_status;
}