SFTP listing directory - php

I'm trying to make a connection to a secure sftp site, however I'm not able to list the directory,however, it's possible to connect using python "expect" or php"ssh2_connect" but it gives me the following mesg: Received disconnect from xx.xx.xx.
If I use a GUI appliction like winscp I'm able to go to the sftp server and retrieve files.
I need to script it thus a cli interface is needed.
PS: just in case someone ran into this. I'm trying to connect to Avisena.com sftp server

You can do this easily with paramiko, checkout SFTP with Python

Related

What is the best and easiest way to access files within a linux vps using its external ip?

I have a game server running in a vps with centos 6 .
The game server stores its status data on a text file and i want to access this file from my website server with php.
The problem is that it is better to do it without installing something link ftp server on the vps. Also i do not know how to set the ftp account directory to my game server directory.
Anyone knows any other simpler way to do so ?
Thanks.
Use a client which supports SFTP if you are able to connect to your server via SSH.
phpseclib handles the SFTP connection without the need to install an extension. For an example on how to download a file with SFTP go here.
If you don't have a webserver installed on your vps, you can use an sftp connection with php, check this question to help you implement it.
sFTP being available by default on most linux OSs you shouldn't have much trouble doing this;

Connect to Bing Merchant Center using phpseclib

I'm trying to use phpseclib in my project to upload a product feed to Bing's Merchant Center using SFTP. I'm using phpseclib in the same project to upload a product feed to Amazon via SFTP, and it's working correctly, but I can't seem to connect successfully to Bing.
The following code is attempting to connect to Bring:
$sftp = new Net_SFTP(BING_FTP_SERVER);
if (!$sftp->login(BING_FTP_USERNAME, BING_FTP_PASSWORD)) {
exit('Login Failed');
}
When I run this code, there is about a 10 second delay, and then I get an error saying the login failed and:
Cannot connect to feeds.adcenter.microsoft.com. Error 110. Connection timed out
To test the credentials, I connected manually using Filezilla, and it works correctly. However, before connecting, Filezilla shows me a warning saying the server's certificate is unknown and I need to manually approve it before I can connect. When I use Filezilla to connect direclty to Amazon's FTP server, I do NOT receive this warning.
So, I'm wondering if it's possible this warning is causing the issue. Do I need to somehow tell my Ubunut server to trust the certificate on Bing's FTP server, basically mimicking the manual approval I was required to give in Filezilla? Does anyone know how to do this?
According to Bing merchant FAQ, only the FTP or the FTPS is supported. Not the SFTP. The phpseclib supports the SFTP only. The FTPS and SFTP are completely different protocols.
Refer to PHP manual for its FTP functions:
https://www.php.net/manual/en/book.ftp.php

Viewing an FTP server log in PHP

I have a standard filezilla FTP server running on my server and I'm wondering if I can get the log that displays in the interface to appear in a PHP web script (hosted on the same server) so I can monitor the FTP activity remotely.
Is this possible to do? Thanks! :)
Edit: I am aware that I can install the filezilla interface and log into the server interface remotely, however, my main client is a mac and there doesn't seem to be any program that can preform this task
Well you can just write a script to do this.
A simple way is to just:
<?php
echo file_get_contents('/path/to/ftp/log');
P/S: You can use filezilla on mac as well.

PHP Netbeans, Cannot Connect to server via SFTP

Im trying to connect my project via sFTP. and everytime I run the project it says.
Cannot Connect to Server http://abcd.efg.com
Reason: java.net.UnkownHostException: http://abcd.efg.com
But when I hit ok. the application then starts at my browser. which is weird, I set up the project as New Project, and PHP Application with existing Sources because I already have a project. then set "Run as: remote website (ftp,Sftp)"
use abcd.efg.com instead of http://abcd.efg.com
you cannot connect over sftp and http at the same time :).
Netbeans is expecting the hostname to connect over sftp, surely it doesnt like http://hostname.com over :22

To use cURL FTP does both servers need the PHP cURL library installed?

I'm trying to wrap my brain about how to do this. We need to provide some files within a directory from our servers to our clients' servers via a PHP/Web interface using FTP. I've looked at the FTP capabilities built in to PHP and some custom classes, but someone suggested cURL might be a better option. We will have the FTP login credentials in our database for the application to access. With that information can we use cURL FTP capabilities to do the transfers, knowing our server has libcurl installed, but the clients servers may not? Do both servers have to have it for the FTP function to work?
Or am I completely going about this the wrong way, and have misunderstood how to use cURL and should be looking into an FTP PHP class?
libCURL is a library; it acts as the client.
Your clients need to be running a FTP server but do not need libCURL.
Just to make it super clear, there are 2 computers involved:
Your server, the one that's supposed to provide files to the client using the FTP protocol. That server does not need to have a web server (or PHP) running. The only thing it needs is an FTP server. It also needs to have permissions configured in such a way that there is an account that can access the files through FTP.
Your client's server, the one that's supposed to retrieve files from your server using the FTP protocol. That server needs to have PHP installed, with libCurl. The software on that server needs to access your server using the FTP protocol, providing the user credentials that you configured on your box.
Hope that helps.
It sounds like what you want to do is have the client connect to your PHP script & then push a button to start an FTP transfer that sends a file from your FTP server to their FTP server. If this is the case, then all you need is cURL on your server.

Categories