2

I have installed and enabled SSH2 in my CentOS WHM/CPanel server, here is from PHP INFO:

ssh2 SSH2 support enabled extension version 0.11.2 libssh2 version 0.18 banner SSH-2.0-libssh2_0.18 remote forwarding enabled hostbased auth enabled polling support enabled publickey subsystem enabled

Registered PHP Streams https, ftps, compress.zlib, php, file, glob, data, http, ftp, ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp

However, anytime I try to use the SSH2 PHP functions to receive a file, I get this:

Warning: ssh2_scp_recv(/home/XXXX) [function.ssh2-scp-recv]: failed to open stream: Is a directory in /pathtoFile on line 16

Here's the code:

if($connection = ssh2_connect('www.server.com', 22)){
    echo("connected");
}else{
    echo("NOT connected");
}

if(ssh2_auth_password($connection, 'username', 'mypassword')){
    echo("password ok");
}else{
    echo("password WRONG");
}

if(ssh2_scp_recv($connection, '/home/pathtoDLfile', '/home/pathtoLocationDestination')){
    echo("received");
}else{
    echo("NOT received");
}

echo("end");
Paul Sonier
  • 38,903
  • 3
  • 77
  • 117
Shackrock
  • 4,601
  • 10
  • 48
  • 74

2 Answers2

4

It looks like you've specified a directory for the location to save your file to, rather than a filename.

Paul Sonier
  • 38,903
  • 3
  • 77
  • 117
3

Please check '/home/pathtoDLfile' and '/home/pathtoLocationDestination' to ensure that they are file names, not directory.

Note especially that the destination location ('/home/pathtoLocationDestination') needs to be a file name, not just a directory path. You can append your desired filename to the path if you have currently specified only the directory name.

George Cummins
  • 28,485
  • 8
  • 71
  • 90