Please note that the function ssh2_auth_password raises PHP warning(!) on bad authentication. To avoid the warning, use the "silence" ("@") operator.
<?php
$ssh = ssh2_connect($host);
if (false === $ssh) {
die('connection failed');
}
$auth = @ssh2_auth_password($ssh, $user, $password);
if (false === $auth) {
die('authentication failed');
}
?>