Press ESC to close

Php ile Hp switche SSh Bağlantısı Komut Gönderme

İNDİRMEK VEYA GÖRÜNTÜLEMEK İÇİN 60 SANİYE BEKLEYİN. İÇERİK OTOMATİK AÇILACAKTIR....

<?php
// HP switch'in IP adresini ve yönetici kullanıcı adı/şifresini tanımlayın
$switchIP = '192.168.0.1';
$username = 'admin';
$password = 'password';

// Komutları içeren bir dizi oluşturun
$commands = [
    'show interfaces',
    'show vlan',
    'show running-config'
];

// Komutları HP switch'e gönderen bir fonksiyon tanımlayın
function sendCommandsToSwitch($switchIP, $username, $password, $commands) {
    // SSH bağlantısını kurun
    $connection = ssh2_connect($switchIP, 22);
    if (!$connection) {
        die('SSH bağlantısı kurulamadı.');
    }

    // SSH kimlik doğrulamasını gerçekleştirin
    if (!ssh2_auth_password($connection, $username, $password)) {
        die('Kimlik doğrulaması başarısız.');
    }

    // Komutları işleyin
    foreach ($commands as $command) {
        // SSH oturumu başlatın
        $shell = ssh2_shell($connection, 'vt102', null, 80, 40, SSH2_TERM_UNIT_CHARS);
        if (!$shell) {
            die('SSH oturumu başlatılamadı.');
        }

        // Komutu gönderin
        fwrite($shell, $command . PHP_EOL);

        // Çıktıyı alın
        $output = '';
        while ($line = fgets($shell)) {
            $output .= $line;
        }

        // Çıktıyı ekrana yazdırın veya başka bir şekilde işleyin
        echo 'Komut: ' . $command . PHP_EOL;
        echo 'Çıktı: ' . $output . PHP_EOL;

        // SSH oturumunu kapatın
        fclose($shell);
    }

    // SSH bağlantısını kapatın
    ssh2_disconnect($connection);
}

// Komutları switch'e gönderin
sendCommandsToSwitch($switchIP, $username, $password, $commands);
?>

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

@Katen on Instagram
Bu hata mesajını yalnızca WordPress yöneticileri görebilir

Hata: 1 kimliğine sahip hiçbir akış bulunamadı.

Bir akış oluşturmak için lütfen Instagram Akışı ayarlar sayfasına gidin.