Doc #54665 [Com]: CURLOPT_SSH_PUBLIC_KEYFILE and CURLOPT_SSH_PRIVATE_KEYFILE are not documented
| From: | php dot proging at gmail dot com | Date: | Thu, 05 May 2011 07:50:01 +0000 |
| Subject: | Doc #54665 [Com]: CURLOPT_SSH_PUBLIC_KEYFILE and CURLOPT_SSH_PRIVATE_KEYFILE are not documented | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-6345@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54665&edit=1
ID: 54665
Comment by: php dot proging at gmail dot com
Reported by: bhaskarna at yahoo dot com
Summary: CURLOPT_SSH_PUBLIC_KEYFILE and
CURLOPT_SSH_PRIVATE_KEYFILE are not documented
Status: Open
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
also, when you change to CURLPROTO_SCP:
$ diff -u b.php a.php
--- b.php 2011-05-05 07:42:56.000000000 +0000
+++ a.php 2011-05-05 07:42:44.000000000 +0000
@@ -6,10 +6,10 @@
$ch = curl_init();
$localfile = 'scp-small-file.txt';
$fp = fopen($localfile, 'r');
- curl_setopt($ch, CURLOPT_URL,
'sftp://@72.246.194.54/21996/'.$localfile);
+ curl_setopt($ch, CURLOPT_URL,
'scp://@72.246.194.54/21996/'.$localfile);
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch,CURLOPT_VERBOSE, 1);
- curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_SFTP);
+ curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_SCP);
curl_setopt($ch, CURLOPT_SSH_PUBLIC_KEYFILE, $certPath);
curl_setopt($ch, CURLOPT_SSH_PRIVATE_KEYFILE, $keyPath);
curl_setopt($ch, CURLOPT_USERPWD,'sshacs');
it doesn't work and throws the following error:
* About to connect() to 72.246.194.54 port 22 (#0)
* Trying 772.246.194.54... * connected
* Connected to t72.246.194.54 (772.246.194.54) port 22 (#0)
* SSH authentication methods available: publickey,keyboard-interactive
* Using ssh public key file
/home/y/conf/yapache/ssh-keys/akamai.id_rsa.pub
* Using ssh private key file
/home/y/conf/yapache/ssh-keys/akamai.id_rsa
* Initialized SSH public key authentication
* Authentication complete
* SSH CONNECT phase done
* scp: '/scp-small-file.txt': No such file or directory
* Connection #0 to host 72.246.194.54 left intact
* Closing connection #0
File upload error. 79
Previous Comments:
------------------------------------------------------------------------
[2011-05-05 09:20:52] bhaskarna at yahoo dot com
Description:
------------
CURLOPT_SSH_PUBLIC_KEYFILE and CURLOPT_SSH_PRIVATE_KEYFILE are not
documented. They are useful when we require to scp or sftp a file thru
curl api.
I could achieve successful sftp using above said curl_setopts
Test script:
---------------
<?php
$certPath="/home/y/conf/yapache/ssh-keys/akamai.id_rsa.pub";
$keyPath="/home/y/conf/yapache/ssh-keys/akamai.id_rsa";
error_reporting(E_ALL);
ini_set('display_errors', 1);
$ch = curl_init();
$localfile = 'scp-small-file.txt';
$fp = fopen($localfile, 'r');
curl_setopt($ch, CURLOPT_URL,
'sftp://@72.246.194.54/21996/'.$localfile);
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch,CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_SFTP);
curl_setopt($ch, CURLOPT_SSH_PUBLIC_KEYFILE, $certPath);
curl_setopt($ch, CURLOPT_SSH_PRIVATE_KEYFILE, $keyPath);
curl_setopt($ch, CURLOPT_USERPWD,'sshacs');
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
curl_exec ($ch);
$error_no = curl_errno($ch);
curl_close ($ch);
if ($error_no == 0) {
$error = 'File uploaded succesfully.';
} else {
$error = 'File upload error.';
}
echo $error.' '.$error_no;
?>
* About to connect() to 72.246.194.54 port 22 (#0)
* Trying 72.246.194.54... * connected
* Connected to 72.246.194.54 (72.246.194.54) port 22 (#0)
* SSH authentication methods available: publickey
* Using ssh public key file
/home/y/conf/yapache/ssh-keys/akamai.id_rsa.pub
* Using ssh private key file
/home/y/conf/yapache/ssh-keys/akamai.id_rsa
* Initialized SSH public key authentication
* Authentication complete
* Connection #0 to host 72.246.194.54 left intact
* Closing connection #0
File uploaded succesfully. 0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54665&edit=1