firstly, I connect to a relay switch:
Code:
$connection = ssh2_connect('Relay.com', 22);
if (!$connection)
{
    die("Connection failed");
}
else
{
    echo "connect OK";
}

if (!ssh2_auth_password($connection, 'username', 'password'))
{
    die("Auth failed");
}
else
{
    echo "login OK";
...