I want to connect to sftp server. Code I am using is..
$connection = ssh2_connect('hostip');
if (!ssh2_auth_password($connection, 'username', 'password')) {
throw new Exception('Unable to connect.'); }
if (!$sftp = ssh2_sftp($connection)) {
throw new Exception('Unable to create SFTP connection.'); }
But showing error as_
This page isn’t working. currently unable to handle this request. HTTP ERROR 500
Main Purpose of doing so is - I want to access file filename.txt
from sample.php
Path is_ /var/data/hostdata/myadmin/public_html/new1/new2/sample.php
& want to access
/var/data/vmail/updates.com/admin/curDir/filename.txt
But PHP
is mapped till /var/data/hostdata/myadmin/public_html
So unable to get proper path. That's the reason I want to create new sftp connection
At first try connection via ssh2(command prompt), after that check your iptables and firewalld, an again check your log files from client and server side, if you come out of the internet behind a firewall then check roles.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.