Laravel SSH on Windows Server

I have a Laravel 4.2 project hosted on a single server (Server A ), and I need to be able to download files from this application, and the files will be transferred to a Windows server located on the same local network (server B ).

I installed OpenSSH on a Windows server and started the service. I can confirm that this works because I can successfully connect in the terminal on server A.

In the Laravel project, I created a connection in the app / config / remote.php file.

But when I try to run the command in a Laravel project on server A using the following code:

SSH::into('ServerB')->run(['IF EXIST folder (echo YES) ELSE (echo NO)'], function($line){ echo $line.PHP_EOL; }); 

I get the following error:

 unpack(): Type N: not enough input, need 4, have 1 

I get this error for every command I try to run on server B. Oddly enough, if I try to use the same code, but point it to a Linux server, the code will work fine. This would make me believe that the SSH server was probably configured incorrectly on server B , but the fact that I can connect via SSH to server B from server A in the terminal window is a bit confusing!

Does anyone know the meaning of the error I get?

+6
source share
3 answers

Laravel 4.2 SSH is the Facade that will enable Illuminate\Remote\RemoteManager . Its into() method returns an instance of Illuminate\Remote\Connection , which then uses an instance of SecLibGateway , which encapsulates the phpseclib library. SecLibGateway will return an instance of phpseclib System_SSH_Agent (see SSH_Agent.php in the vendor/phpseclib/phpseclib/phpseclib/System in a Laravel 4.2 installation). Inside the constructor for System_SSH_Agent, on line 248:

 $this->fsock = fsockopen('unix://' . $address, 0, $errno, $errstr); 

Opens a socket connection to unix: //. OP said that SSH runs on a Linux server, but not on a Windows server. I believe this may be a criminal. There are several calls to the PHP unpack() function, for example, on line 274:

 $length = current(unpack('N', fread($this->fsock, 4))); 

It calls unpack () with type N with 4 required inputs. Somehow fsock is invalid and causes an error message.

+2
source

This is probably a problem with phpseclib . Check if the latest version is installed, if possible, update it.

+5
source

It seems that such errors appear when "a warning appears when the input is incorrect" cfr this post

This may be due to the setting in php.ini, that is, magic_quotes_runtime works by adding backslashes in content read from external sources, such as text files, effectively destroying a binary input, such as a .mo file, and also destroying configuration settings. from the database ... " cfr this post

+1
source

All Articles