A data supplier have requested a public SSH key for using their SFTP server. They have supplied us with:
- Username
- Password
- Hostname
- Port
I am attempting to use the stream wrapper ssh2.sftp//
within php using private key and username/password. My code is as follows:
$options = array(
'ssh2' => array(
'privkey_file' => '/path/to/priv_key',
),
);
$context = stream_context_create($options);
fopen('ssh2.sftp://<username>:<password>@<host>:<port>', 'rb', false, $context);
Results:
Warning: fopen(ssh2.sftp://...@<ip>...): failed to open stream: operation failed in ...
I can connect using linux's sftp command, so I know that the connection works and the credentials are working just fine.
sftp -oPort=<port> -i /path/to/priv_key -v <username>@<host>
Results:
Authenticated with partial success.
password: <password-entered>
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Sending subsystem: sftp
sftp>
Does anyone have any ideas?
I am open to ideas using the ssh2 functions, but I am strongly wanting to use the file system and stream functions.