ssh2_tunnel

(PECL ssh2 >= 0.9.0)

ssh2_tunnelAbre um túnel através de um servidor remoto

Descrição

ssh2_tunnel(resource $session, string $host, int $port): resource

Abre um fluxo de soquete para um host/porta arbitrário por meio do servidor SSH conectado no momento.

Parâmetros

session

Um identificador de conexão SSH, obtido de uma chamada a ssh2_connect().

host

port

Valor Retornado

Exemplos

Exemplo #1 Abrindo um túnel para um host arbitrário

<?php
$connection
= ssh2_connect('shell.example.com', 22);
ssh2_auth_pubkey_file($connection, 'usuario', 'id_dsa.pub', 'id_dsa');

$tunnel = ssh2_tunnel($connection, '10.0.0.101', 12345);
?>

Veja Também

adicione uma nota

Notas Enviadas por Usuários (em inglês) 1 note

up
1
marc
9 years ago
ssh2_tunnel returns a socket stream (e.g, the output of fsockopen). You can use something basic like this to send a line break and get any output back to test that it's working:

fwrite($tunnel, "\n");
while (!feof($tunnel)) {
echo fgets($tunnel, 128);
}

Just a reminder: you can't currently use the socket with any of the cURL functions.
To Top