4
When using Winscp I perform the following steps: (fictitious data)
hostname: bala.rimunivert.com.br username: zzzzzzz@rjozzz 000
after that he asks Gateway username: juliohenrique Password gateway: 1234566
and after that still appears: authentic futher required and then I put another password: blablabalaba
That is, as far as I understand to access this server, I need to authenticate myself to another one first. The doubt that generates me is the following, how to implement this in my code ?
//esse é um metodo de conexao da minha classe ftp
public function connect ($server, $ftpUser, $ftpPassword, $isPassive = false){
// *** Set up basic connection
$this->connectionId = ftp_connect($server);
// *** Login with username and password
$loginResult = ftp_login($this->connectionId, $ftpUser, $ftpPassword);
// *** Sets passive mode on/off (default off)
ftp_pasv($this->connectionId, $isPassive);
// *** Check connection
if ((!$this->connectionId) || (!$loginResult)) {
$this->logMessage('FTP connection has failed!');
$this->logMessage('Attempted to connect to ' . $server . ' for user ' . $ftpUser, true);
return false;
} else {
$this->logMessage('Connected to ' . $server . ', for user ' . $ftpUser);
$this->loginOk = true;
return true;
}
}
//minhas constantes definidas
define('FTP_HOST', 'bala.rimunivert.com.br');
define('FTP_USER', 'juliohenrique');
define('FTP_PASS', '1234566');
//como eu chamo esse metodo e algum arquivo
$ftpObj -> connect(FTP_HOST, FTP_USER, FTP_PASS);
This code would work if I didn’t have to authenticate myself on another server before accessing the server I want. I don’t know if it’s clear, but someone can help me make this connection?
how I can connect to send files on this type of network ?
**Guys, someone give me a light! by winscp I connect by marking the SFTP option, what does it mean?
Is there any way to do this using only PHP native functions?
– Julio Henrique
I don’t know otherwise, the server that is running your PHP code has to have access to the FTP server either directly or with a proxy, but I want to track if any ninja knows more about it..
– Samuel Fontebasso
I can’t access that lib proxy here blocks haha, I’ll have to see at home.
– Julio Henrique
Right, take advantage and make a drawing of the architecture of this network, so we can help more!!
– Samuel Fontebasso
from what I understand here is just a proxy that needs to be authenticated before accessing the server ftp. You think with phpseclib I can do this?
– Julio Henrique
@Juliohenrique97 is why I asked for the architecture, I understood that there is a server in the middle that has access to the server with FTP. This is very common in corporate networks, but if it is a proxy you can use native PHP functions
– Samuel Fontebasso