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");
1
  • 1
    You sure you have the path to the file correct? '/home/username/pathtoDLfile', maybe? Commented Jul 11, 2011 at 16:55

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.