I am using
- php7
- Ubuntu 16.04.1 LTS
I am trying to make a ssh2_connect connection using ssh2_auth_password, the reason for this is to get files from another server
I am getting error as below PHP Fatal error: Uncaught Error: Call to undefined function ssh2_connect()
$connection = ssh2_connect($connectionIp, 22, array('hostkey'=>'ssh-rsa'));
if (ssh2_auth_password($connection, 'username', 'password')) { echo "Authentication Successful!\n"; } else { die('Authentication Failed...'); }I have install as below:
sudo apt-get install libssh2-php && sudo /etc/init.d/apache2 restartI get the message
Package libssh2-php is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
php-ssh2:i386 php-ssh2
E: Package 'libssh2-php' has no installation candidateI used to use the same code for
- php5
- ubuntu 14.04
This above code worked perfectly when I am upgraded to PHP and ubuntu higher version this code doesn't work.
Thanks in advance for all you suggestion.
1 Answer
After struggling for 2 days, My Linux Administrator suggested to install this package below.
sudo apt install php-ssh2After installing the above package my ssh2_connect undefined function vanished.
1