put() public method

By default, \phpseclib\Net\SCP::put() does not read from the local filesystem. $data is dumped directly into $remote_file. So, for example, if you set $data to 'filename.ext' and then do \phpseclib\Net\SCP::get(), you will get a file, twelve bytes long, containing 'filename.ext' as its contents. Setting $mode to self::SOURCE_LOCAL_FILE will change the above behavior. With self::SOURCE_LOCAL_FILE, $remote_file will contain as many bytes as filename.ext does on your local filesystem. If your filename.ext is 1MB then that is how large $remote_file will be, as well. Currently, only binary mode is supported. As such, if the line endings need to be adjusted, you will need to take care of that, yourself.
public put ( string $remote_file, string $data, integer $mode = self::SOURCE_STRING, callable $callback = null ) : boolean
$remote_file string
$data string
$mode integer
$callback callable
return boolean
 /**
  * Create backup user over ssh
  * @param string $addr
  * @param string $port
  * @return mixed (false or identity of the router)
  */
 public function createBackupAccount($addr, $port)
 {
     $bcpuser = $this->config['routerboard']['backupuser'];
     $keyname = 'id_rsa-backup-user.pub';
     if ($ssh = $this->sshConnect($addr, $port, false)) {
         $scp = new SCP($ssh);
         if (!$scp->put($keyname, $this->config['system']['ssh-dir'] . DIRECTORY_SEPARATOR . 'id_rsa.pub', SCP::SOURCE_LOCAL_FILE)) {
             $this->logger->log("The SSH-RSA file copy to the :'" . $addr . "' router fails!", $this->logger->setError());
             return false;
         }
         $ssh->exec('user add name=' . $bcpuser . ' group=full');
         sleep(1);
         $ssh->exec('user ssh-keys import user='******' public-key-file=' . $keyname);
         sleep(1);
         if ($ssh->exec('user comment ' . $bcpuser . ' comment="Backup User"')) {
             $this->logger->log("Creating of the backup account '" . $bcpuser . "' fails!", $this->logger->setError());
             return false;
         }
         sleep(1);
         $identity = $ssh->exec('system identity print');
         $identity = trim(str_replace('name:', '', trim($identity)));
         $this->logger->log("The backup account '" . $bcpuser . "' at '" . $identity . "'@'" . $addr . "' has been created successfully!");
         $this->sshDisconnect($ssh);
         return $identity;
     }
     return false;
 }
 /**
  * @depends testConstructor
  * @param \phpseclib\Net\SCP $scp
  */
 public function testPutGetString($scp)
 {
     $this->assertTrue($scp->put(self::$remoteFile, self::$exampleData), 'Failed asserting that data could successfully be put() into file.');
     $content = $scp->get(self::$remoteFile);
     // TODO: Address https://github.com/phpseclib/phpseclib/issues/146
     $this->assertContains(strlen($content), array(self::$exampleDataLength, self::$exampleDataLength + 1), 'Failed asserting that string length matches expected length.');
     $this->assertContains($content, array(self::$exampleData, self::$exampleData . ""), 'Failed asserting that string content matches expected content.');
     return $scp;
 }