phpseclib

How to suppress phpseclib “Invalid HMAC” warning

痴心易碎 提交于 2019-12-08 09:48:40
问题 I am using phpseclib to transfer files via SFTP, but login fails with Invalid HMAC I need to ignore this server warning. For example with curl command I use the -k option. Can I do the same with phplibsec? -k, --insecure (SSL) This option explicitly allows curl to perform "insecure" SSL connections and transfers. All SSL connections are attempted to be made secure by using the CA certificate bundle installed by default. This makes all connections considered "insecure" fail unless -k, -

how to serialize phpseclib?

给你一囗甜甜゛ 提交于 2019-12-08 07:19:08
问题 I have been trying to serialize phpseclib connection since I am loading some php pages from ajax and I dont want to reconnect again and again. Page 1 - define SSH2 First require("Net/SSH2.php"); session_start(); $ssh = new Net_SSH2 ("localhost"); if ($ssh->login($username, $pass)) { $_SESSION['obj'] = serialize($ssh); }else{ echo "Invalid Login !!!"; } Page 2 - Get Stored session with unserialize session_start(); require("Net/SSH2.php"); $ssh = unserialize($_SESSION['obj']); echo $ssh->exec(

PHP OpenSSL - openssl_private_encrypt crashes webpage

穿精又带淫゛_ 提交于 2019-12-08 03:39:56
问题 This has been reported at bugs.php.net. If I replace libeay32.dll and ssleay32.dll in xampp/apache/bin with the same files in xampp/php/ then it works but I CANNOT use SSL I need to use SSL, has anyone been able to resolve this? I am using OpenSSL library in PHP (5.4.7) on XAMPP (1.8.1) for encryption, decryption, etc. I am also using SSL on localhost. I am able to create the private-public key pair using openssl_pkey_new() method and generate the certificate as well. But when I try to access

How to convert phpseclib's CRYPT_RSA_SIGNATURE_PKCS1 to node

旧巷老猫 提交于 2019-12-07 07:28:51
问题 How to convert PHP's $rsa->verify function to node? I used the crypto's verify function like this: const crypto = require('crypto'); const verify = crypto.createVerify('RSA-SHA256'); verify.update('some data to sign'); const public_key = getPublicKeySomehow(); const signature = getSignatureToVerify(); console.log(verify.verify(public_key, signature)); But it always return false. When I run my data and the signature through php it returns true! Any idea what I might be doing wrong? The php

Get last 15 lines from a large file in SFTP with phpseclib [duplicate]

对着背影说爱祢 提交于 2019-12-07 06:07:25
This question already has answers here : How do you get last some lines of file via SFTP in PHP (3 answers) Closed 10 months ago . I want to get the last 15 lines from a large file (30MB) from a SFTP server using PHP. I tried using the phpseclib's SFTP functionality like that: include('./Net/SFTP.php'); $sftp = new Net_SFTP("server", 2022); if (!$sftp->login('username', 'password')) { exit("Login error"); } $size = $sftp->size('./file.txt'); $Container = nl2br($sftp->get('./file.txt', false, $size - 5000)); if( !empty($Container) ) { echo $Container; } else { exit("empty file"); } But this

connect to the mysql database using phpseclib library

回眸只為那壹抹淺笑 提交于 2019-12-07 00:25:27
I have successfully connect to the My VPS using phpscelib library.Now i want to connect to my existing database.Please help me for this ? <?php set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib'); include('Net/SSH2.php'); $ssh = new Net_SSH2('192.ccc.ccc.ccc'); if (!$ssh->login('ccc', 'cccc')) { exit('Login Failed'); } echo $ssh->exec("I need to put MySql commands here"); ?> First, wouldn't it be better to allow remote access for that user to mysql? However, I don't know your reasons. The most common an transparent way would be create a ssh tunnel. This can be done in two

how to serialize phpseclib?

北城以北 提交于 2019-12-06 19:43:27
I have been trying to serialize phpseclib connection since I am loading some php pages from ajax and I dont want to reconnect again and again. Page 1 - define SSH2 First require("Net/SSH2.php"); session_start(); $ssh = new Net_SSH2 ("localhost"); if ($ssh->login($username, $pass)) { $_SESSION['obj'] = serialize($ssh); }else{ echo "Invalid Login !!!"; } Page 2 - Get Stored session with unserialize session_start(); require("Net/SSH2.php"); $ssh = unserialize($_SESSION['obj']); echo $ssh->exec('ls'); I want to put Login information in $_SESSION['obj'] too so Whenever I am on that php page i just

Integrate phpseclib into Laravel 5

≡放荡痞女 提交于 2019-12-06 08:44:58
问题 i am currently migrating my Project from Laravel 4 to Laravel 5, i am still a novice user of Laravel and OOP as well but everything went smoothly so far. However, in my L4 project I use the phpseclib for generating SSH keys which I imported in the following way: MyController.php ... include('../app/libs/phpseclib0.3.10/Crypt/RSA.php'); $rsa = new Crypt_RSA(); ... which does not seems to work anymore: syntax error, unexpected 'if' (T_IF), expecting identifier (T_STRING) .../app/libs/phpseclib0

Downloading file matching pattern using phpseclib

﹥>﹥吖頭↗ 提交于 2019-12-05 06:14:52
问题 I am trying to download a file from a SFTP server. I have managed to connect to it and download the files. The problem is that the file in the server will be updated daily and part of the filename is the exact time when it is generated which is unpredictable. How can I implement my PHP script so it downloads any XML file which name starts with a certain pattern but I don't know the exact full name? 回答1: You have to retrieve a list of all files in the remote directory using Net_SFTP::nlist.

How do i set flags when using phpseclib ssh2 exec() function?

南楼画角 提交于 2019-12-05 02:12:55
问题 I'm using phpseclib and need to make a couple of php functions that enable someone to programmatically ssh into their server and change the root password and also change the password of a user that may have forgotten their password (so have to be logged in as root). I tried using libssh2, but found it a bit nasty to use. I'm now looking at phpseclib which seems more robust. But when I tried to use the 'su' command like so: echo $ssh->exec('su'); I get the reply: su: must be run from a