Be careful when providing a specific hostkey order.
<?php
ssh2_connect('IP', 'port', array('hostkey'=>'ssh-rsa, ssh-dss'));
?>
Will only work when the public key of the server is RSA, and not DSA also as expected. This is caused by the empty space before the "ssh-dss".
So a similar code:
<?php
ssh2_connect('IP', 'port', array('hostkey'=>'ssh-rsa,ssh-dss'));
?>
Will work. The HOSTKEY method is overriden using exactly what you write, so no empty spaces are allowed.
This took me some time that you could save ;)