Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module 'ssh2' already loaded in Unknown on line 0

Tags:

php

ssh

I use the functions below to copy files from one server to another. It works most of the time, but sometimes I start getting this error in log files:

Module 'ssh2' already loaded in Unknown on line 0

And it stops copying. Later for some reason, the error will stop and copying will start working again. What is the issue here?

function getConn($server,$username,$password)
{
    $connection = 0;

    if (function_exists("ssh2_connect")) 
    {
        $connection = ssh2_connect($server, 3817);
        if($connection)
        {
            if(ssh2_auth_password($connection, $username, $password))
            {
                return $connection;
            }
        }
    }
    return 0;
}
function scp($server,$username,$password,$remotepath,$localpath)
{
    $connection = 0;
    $connection = $this->getConn($server,$username,$password);
    if($connection)
    {
        $ret = ssh2_scp_send($connection, $localpath, $remotepath, 0644);
        ssh2_exec($connection, 'exit'); 
    }
}
like image 647
HyderA Avatar asked Jan 18 '11 15:01

HyderA


1 Answers

The error message Module 'ssh2' already loaded in Unknown on line 0 means that there's something off in your PHP configuration. Check to see if there's a line that says extension=ssh2.so in your php.ini. If so, remove it and check if everything is still working. Possibly, the extension=ssh2.so is loaded twice, meaning PHP will complain that the module is already loaded.

Good luck.

like image 51
Berry Langerak Avatar answered Oct 13 '22 00:10

Berry Langerak