David,
This script should hopefully provide some info about any possible permissions issues (although on Windows things don't usually work that well). But give it a try and let us know.
Can you run the following simple script - place it in the same location as your keys - and paste the output here? I still suspect some sort of a permissions issue
<?php
// apparently on windows get_current_user() returns the owner of the process running the script
echo get_current_user(), '<br />';
// apparently on windows get_current_user() returns the owner of the process running the script
echo get_current_user(), '<br />';
// this will probably not work correctly on windows
echo getmyuid(), '<br />';
$publicKeyInfo = stat($publicKey = '/full/path/to/your/public/key');
$privateKeyInfo = stat($privateKey = '/full/path/to/your/private/key');
if ($publicKeyInfo) {
echo '<pre>';
print_r($publicKeyInfo);
echo '</pre>';
} else {
echo 'Stat failed for public key <br />';
}
if ($privateKeyInfo) {
echo '<pre>';
print_r($privateKeyInfo);
echo '</pre>';
} else {
echo 'Stat failed for private key <br />';
}
set_error_handler(function ($errno, $errstr) {
echo "[$errno] $errstr <br />";
});
file_get_contents($privateKey);
file_get_contents($publicKey);
echo getmyuid(), '<br />';
$publicKeyInfo = stat($publicKey = '/full/path/to/your/public/key');
$privateKeyInfo = stat($privateKey = '/full/path/to/your/private/key');
if ($publicKeyInfo) {
echo '<pre>';
print_r($publicKeyInfo);
echo '</pre>';
} else {
echo 'Stat failed for public key <br />';
}
if ($privateKeyInfo) {
echo '<pre>';
print_r($privateKeyInfo);
echo '</pre>';
} else {
echo 'Stat failed for private key <br />';
}
set_error_handler(function ($errno, $errstr) {
echo "[$errno] $errstr <br />";
});
file_get_contents($privateKey);
file_get_contents($publicKey);
This script should hopefully provide some info about any possible permissions issues (although on Windows things don't usually work that well). But give it a try and let us know.
On Mon, Feb 1, 2021 at 9:53 PM David Spector <david025@xxxxxxxxxxxxxxxxxxxxxx> wrote:
To all: I found out how to run SSH and I ran this:
ssh -p PORT -i KEY user@host
After verifying the new key, it gave me a remote command prompt!
Note that the user's password was not needed, nor the public key file!
So why can't I get sftp working in PHP using the same credentials?
Any experts here?
(I've run out of free time to reply interactively)
David