ssh2_connect unable to connect


Maybe someone can help me.

I have a dedicated server and I’m using OpenVZ to create individual VPSs for different functions.

I have VPS 1 using Centos 6.5 setup using cPanel for the website domain name and scripts for the website.
VPS1 has PHP 5.4.31. I have installed PECL ssh2 on VPS 1 and it shows up in PHPINFO().
When I ssh into the VPS and do this command:

php -m |grep ssh2 the output is ssh2.

Here is the output from PHPINFO():

SSH2 support enabled

extension version 0.12
libssh2 version 1.4.4-20140820
banner SSH-2.0-libssh2_1.4.4-20140820

I have VPS 2 using Ubuntu 12.04 to store uploaded files from clients.This VPS has no domain name only 1 IP.
There is no firewall on VPS 2

I want to connect from VPS 1 to VPS 2 to create directories for each client and transfer files and test if files are already there and if so overwrite the file with a new version.

Here is a snippet of my simple script:

$connection = ssh2_connect(“”, $ip_port);
ssh2_auth_password($connection, $ip_user, $ip_pw);
$sftp = ssh2_sftp($connection);

It fails on first line
Warning: ssh2_connect(): Unable to connect to on port YYYY

These are the same login data that I use to login manually using Putty.

If anyone can help it would be appreciated OR if anyone can suggest a different way to make directories, store and overwrite files in a remote server it would be appreciated.

Thank you in advance.



I finally got this to work using phpseclib and it was very easy to install. All you have to do is place the directories that you download from Sourceforge ( in the include path and start using the features as discussed at