How to connect SFTP in magento 2Invalid Post Data - Magento ConnectAdding magento themes without connectMagento Connect Manager Connect Error: Fail to open a fileHow to upload Extension files in magento ConnectMagento Connect Manager not updated?Magento Connect: Release not createdMagento Connect: cannot connect to the hostMagento 1.9.2.4 cURL issueMagento 2.3 Inject helper into controller object type error?MsrpPriceCalculator Exception

Does a dangling wire really electrocute me if I'm standing in water?

If a centaur druid Wild Shapes into a Giant Elk, do their Charge features stack?

Why was the "bread communication" in the arena of Catching Fire left out in the movie?

Is every set a filtered colimit of finite sets?

extract characters between two commas?

Could a US political party gain complete control over the government by removing checks & balances?

Prime joint compound before latex paint?

What does "enim et" mean?

How to create a consistent feel for character names in a fantasy setting?

Why do UK politicians seemingly ignore opinion polls on Brexit?

COUNT(id) or MAX(id) - which is faster?

Is it legal to have the "// (c) 2019 John Smith" header in all files when there are hundreds of contributors?

Synthetic Control Method

Finding files for which a command fails

Latin words with no plurals in English

Eliminate empty elements from a list with a specific pattern

Does it makes sense to buy a new cycle to learn riding?

Lied on resume at previous job

aging parents with no investments

Symmetry in quantum mechanics

How many letters suffice to construct words with no repetition?

Are white and non-white police officers equally likely to kill black suspects?

Extreme, but not acceptable situation and I can't start the work tomorrow morning

What is GPS' 19 year rollover and does it present a cybersecurity issue?



How to connect SFTP in magento 2


Invalid Post Data - Magento ConnectAdding magento themes without connectMagento Connect Manager Connect Error: Fail to open a fileHow to upload Extension files in magento ConnectMagento Connect Manager not updated?Magento Connect: Release not createdMagento Connect: cannot connect to the hostMagento 1.9.2.4 cURL issueMagento 2.3 Inject helper into controller object type error?MsrpPriceCalculator Exception






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want to connect the SFTP in Magento 2



here is my code.



use MagentoFrameworkAppBootstrap;
require __DIR__ . '/app/bootstrap.php';

$bootstrap = Bootstrap::create(BP, $_SERVER);

$objectManager = $bootstrap->getObjectManager();

$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('frontend');

$sftp = $objectManager->create('MagentoFrameworkFilesystemIoSftp');
$open = $sftp->open(array('host' => 'hostname','username' => 'username',
'password' => 'password',));

if ($open)

echo "true";

else

echo "false";



but does not work that code.










share|improve this question






























    0















    I want to connect the SFTP in Magento 2



    here is my code.



    use MagentoFrameworkAppBootstrap;
    require __DIR__ . '/app/bootstrap.php';

    $bootstrap = Bootstrap::create(BP, $_SERVER);

    $objectManager = $bootstrap->getObjectManager();

    $state = $objectManager->get('MagentoFrameworkAppState');
    $state->setAreaCode('frontend');

    $sftp = $objectManager->create('MagentoFrameworkFilesystemIoSftp');
    $open = $sftp->open(array('host' => 'hostname','username' => 'username',
    'password' => 'password',));

    if ($open)

    echo "true";

    else

    echo "false";



    but does not work that code.










    share|improve this question


























      0












      0








      0








      I want to connect the SFTP in Magento 2



      here is my code.



      use MagentoFrameworkAppBootstrap;
      require __DIR__ . '/app/bootstrap.php';

      $bootstrap = Bootstrap::create(BP, $_SERVER);

      $objectManager = $bootstrap->getObjectManager();

      $state = $objectManager->get('MagentoFrameworkAppState');
      $state->setAreaCode('frontend');

      $sftp = $objectManager->create('MagentoFrameworkFilesystemIoSftp');
      $open = $sftp->open(array('host' => 'hostname','username' => 'username',
      'password' => 'password',));

      if ($open)

      echo "true";

      else

      echo "false";



      but does not work that code.










      share|improve this question
















      I want to connect the SFTP in Magento 2



      here is my code.



      use MagentoFrameworkAppBootstrap;
      require __DIR__ . '/app/bootstrap.php';

      $bootstrap = Bootstrap::create(BP, $_SERVER);

      $objectManager = $bootstrap->getObjectManager();

      $state = $objectManager->get('MagentoFrameworkAppState');
      $state->setAreaCode('frontend');

      $sftp = $objectManager->create('MagentoFrameworkFilesystemIoSftp');
      $open = $sftp->open(array('host' => 'hostname','username' => 'username',
      'password' => 'password',));

      if ($open)

      echo "true";

      else

      echo "false";



      but does not work that code.







      magento2.3 magento-connect file






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 10 hours ago









      ARUNPRABAKARAN M

      403113




      403113










      asked Feb 27 at 9:58









      Rasik MiyaniRasik Miyani

      648




      648




















          2 Answers
          2






          active

          oldest

          votes


















          0














          Kindly install PHP ssh2 extension and then use the following code.



          $strServer = '*******';
          $strServerPort = '*******';
          $strServerUsername = '*******';
          $strServerPassword = '*******';

          //connect to server
          $resConnection = ssh2_connect($strServer, $strServerPort);

          if(ssh2_auth_password($resConnection, $strServerUsername, $strServerPassword))

          //Initialize SFTP subsystem
          echo "connected";






          share|improve this answer
































            0














            I've tested your code, but it works fine, except for the if statement. That if statement always returns false, even if the connection is open. So i've added a var_dump at the end. It lists all existing files in the root of the SFTP server. With that var_dump you can verify the SFTP connection.



            <?php

            use MagentoFrameworkAppBootstrap;
            require __DIR__ . '/app/bootstrap.php';

            $bootstrap = Bootstrap::create(BP, $_SERVER);

            $objectManager = $bootstrap->getObjectManager();

            $state = $objectManager->get('MagentoFrameworkAppState');
            $state->setAreaCode('frontend');

            $sftp = $objectManager->create('MagentoFrameworkFilesystemIoSftp');
            $open = $sftp->open(
            array(
            'host' => 'hostname',
            'username' => 'username',
            'password' => 'password',
            )
            );

            var_dump($sftp->ls());


            Hope this helps






            share|improve this answer

























              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "479"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f263630%2fhow-to-connect-sftp-in-magento-2%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              Kindly install PHP ssh2 extension and then use the following code.



              $strServer = '*******';
              $strServerPort = '*******';
              $strServerUsername = '*******';
              $strServerPassword = '*******';

              //connect to server
              $resConnection = ssh2_connect($strServer, $strServerPort);

              if(ssh2_auth_password($resConnection, $strServerUsername, $strServerPassword))

              //Initialize SFTP subsystem
              echo "connected";






              share|improve this answer





























                0














                Kindly install PHP ssh2 extension and then use the following code.



                $strServer = '*******';
                $strServerPort = '*******';
                $strServerUsername = '*******';
                $strServerPassword = '*******';

                //connect to server
                $resConnection = ssh2_connect($strServer, $strServerPort);

                if(ssh2_auth_password($resConnection, $strServerUsername, $strServerPassword))

                //Initialize SFTP subsystem
                echo "connected";






                share|improve this answer



























                  0












                  0








                  0







                  Kindly install PHP ssh2 extension and then use the following code.



                  $strServer = '*******';
                  $strServerPort = '*******';
                  $strServerUsername = '*******';
                  $strServerPassword = '*******';

                  //connect to server
                  $resConnection = ssh2_connect($strServer, $strServerPort);

                  if(ssh2_auth_password($resConnection, $strServerUsername, $strServerPassword))

                  //Initialize SFTP subsystem
                  echo "connected";






                  share|improve this answer















                  Kindly install PHP ssh2 extension and then use the following code.



                  $strServer = '*******';
                  $strServerPort = '*******';
                  $strServerUsername = '*******';
                  $strServerPassword = '*******';

                  //connect to server
                  $resConnection = ssh2_connect($strServer, $strServerPort);

                  if(ssh2_auth_password($resConnection, $strServerUsername, $strServerPassword))

                  //Initialize SFTP subsystem
                  echo "connected";







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Feb 27 at 10:38









                  user55548

                  33329




                  33329










                  answered Feb 27 at 10:14









                  ARUNPRABAKARAN MARUNPRABAKARAN M

                  403113




                  403113























                      0














                      I've tested your code, but it works fine, except for the if statement. That if statement always returns false, even if the connection is open. So i've added a var_dump at the end. It lists all existing files in the root of the SFTP server. With that var_dump you can verify the SFTP connection.



                      <?php

                      use MagentoFrameworkAppBootstrap;
                      require __DIR__ . '/app/bootstrap.php';

                      $bootstrap = Bootstrap::create(BP, $_SERVER);

                      $objectManager = $bootstrap->getObjectManager();

                      $state = $objectManager->get('MagentoFrameworkAppState');
                      $state->setAreaCode('frontend');

                      $sftp = $objectManager->create('MagentoFrameworkFilesystemIoSftp');
                      $open = $sftp->open(
                      array(
                      'host' => 'hostname',
                      'username' => 'username',
                      'password' => 'password',
                      )
                      );

                      var_dump($sftp->ls());


                      Hope this helps






                      share|improve this answer





























                        0














                        I've tested your code, but it works fine, except for the if statement. That if statement always returns false, even if the connection is open. So i've added a var_dump at the end. It lists all existing files in the root of the SFTP server. With that var_dump you can verify the SFTP connection.



                        <?php

                        use MagentoFrameworkAppBootstrap;
                        require __DIR__ . '/app/bootstrap.php';

                        $bootstrap = Bootstrap::create(BP, $_SERVER);

                        $objectManager = $bootstrap->getObjectManager();

                        $state = $objectManager->get('MagentoFrameworkAppState');
                        $state->setAreaCode('frontend');

                        $sftp = $objectManager->create('MagentoFrameworkFilesystemIoSftp');
                        $open = $sftp->open(
                        array(
                        'host' => 'hostname',
                        'username' => 'username',
                        'password' => 'password',
                        )
                        );

                        var_dump($sftp->ls());


                        Hope this helps






                        share|improve this answer



























                          0












                          0








                          0







                          I've tested your code, but it works fine, except for the if statement. That if statement always returns false, even if the connection is open. So i've added a var_dump at the end. It lists all existing files in the root of the SFTP server. With that var_dump you can verify the SFTP connection.



                          <?php

                          use MagentoFrameworkAppBootstrap;
                          require __DIR__ . '/app/bootstrap.php';

                          $bootstrap = Bootstrap::create(BP, $_SERVER);

                          $objectManager = $bootstrap->getObjectManager();

                          $state = $objectManager->get('MagentoFrameworkAppState');
                          $state->setAreaCode('frontend');

                          $sftp = $objectManager->create('MagentoFrameworkFilesystemIoSftp');
                          $open = $sftp->open(
                          array(
                          'host' => 'hostname',
                          'username' => 'username',
                          'password' => 'password',
                          )
                          );

                          var_dump($sftp->ls());


                          Hope this helps






                          share|improve this answer















                          I've tested your code, but it works fine, except for the if statement. That if statement always returns false, even if the connection is open. So i've added a var_dump at the end. It lists all existing files in the root of the SFTP server. With that var_dump you can verify the SFTP connection.



                          <?php

                          use MagentoFrameworkAppBootstrap;
                          require __DIR__ . '/app/bootstrap.php';

                          $bootstrap = Bootstrap::create(BP, $_SERVER);

                          $objectManager = $bootstrap->getObjectManager();

                          $state = $objectManager->get('MagentoFrameworkAppState');
                          $state->setAreaCode('frontend');

                          $sftp = $objectManager->create('MagentoFrameworkFilesystemIoSftp');
                          $open = $sftp->open(
                          array(
                          'host' => 'hostname',
                          'username' => 'username',
                          'password' => 'password',
                          )
                          );

                          var_dump($sftp->ls());


                          Hope this helps







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Mar 18 at 12:11

























                          answered Mar 4 at 12:34









                          MartinEMartinE

                          127113




                          127113



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Magento Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f263630%2fhow-to-connect-sftp-in-magento-2%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Best approach to update all entries in a list that is paginated?Best way to add items to a paginated listChoose Your Country: Best Usability approachUpdate list when a user is viewing the list without annoying themWhen would the best day to update your webpage be?What should happen when I add a Row to a paginated, sorted listShould I adopt infinite scrolling or classical pagination?How to show user that page objects automatically updateWhat is the best location to locate the comments section in a list pageBest way to combine filtering and selecting items in a listWhen one of two inputs must be updated to satisfy a consistency criteria, which should you update (if at all)?

                              Вунгтау (аеропорт) Загальні відомості | Див. також | Посилання | Навігаційне меню10°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.0833310°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.083337731608Vinh AirportVinh airport facelift improves serviceвиправивши або дописавши їївиправивши або дописавши їїр

                              Тонконіг бульбистий Зміст Опис | Поширення | Екологія | Господарське значення | Примітки | Див. також | Література | Джерела | Посилання | Навігаційне меню1114601320038-241116202404kew-435458Poa bulbosaЭлектронный каталог сосудистых растений Азиатской России [Електронний каталог судинних рослин Азіатської Росії]Малышев Л. Л. Дикие родичи культурных растений. Poa bulbosa L. - Мятлик луковичный. [Малишев Л. Л. Дикі родичи культурних рослин. Poa bulbosa L. - Тонконіг бульбистий.]Мятлик (POA) Сем. Злаки (Мятликовые) [Тонконіг (POA) Род. Злаки (Тонконогові)]Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Description from Flora of China) [Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Опис від Флора Китаю)]Poa bulbosa L. – lipnice cibulkatá / lipnica cibulkatáPoa bulbosa в базі даних Poa bulbosa на сайті Poa bulbosa в базі даних «Global Biodiversity Information Facility» (GBIF)Poa bulbosa в базі даних «Euro + Med PlantBase» — інформаційному ресурсі для Євро-середземноморського розмаїття рослинPoa bulbosa L. на сайті «Плантариум»