开发者

sftp connection

开发者 https://www.devze.com 2023-04-06 19:38 出处:网络
When I\' m trying to connect Sftp from my joomla site its not connecting: $c = ftp_connect(\'ftp.xyz.com\')or die(\"Can\'t connect\");

When I' m trying to connect Sftp from my joomla site its not connecting:

    $c = ftp_connect('ftp.xyz.com')     or die("Can't connect");
    ftp_login($c, 'username' , 'pwd')     or die("Can't login");

in this case msg showing Can't connect

I also tried this code

  $connection = ssh2_connect('ftp.x开发者_StackOverflowyz.com', 22);
  if (!$connection) die('Connection failed');

in this case no error msg showing

Please help me, if there is a proper solution help me please.

Thanks


ftp_connect() uses FTP, not SFTP. They're very different. So if your host is providing only SFTP, then no, that function won't work! SFTP is explained in more detail here:

http://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol

ssh2_connect() is the right connection method to use, which is why it's probably working. You can see all the SSH2 functions available in PHP here:

http://php.net/manual/en/ref.ssh2.php

You'll probably be most interested in ssh2_scp_recv() and ssh2_scp_send() (for getting and sending files).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号