merlinthemagic / MTS

Automation Tools for PHP
GNU Lesser General Public License v3.0
112 stars 29 forks source link

Error Not Handled for Request Type: connectByUsername #55

Open mmsyamsurrijal opened 1 year ago

mmsyamsurrijal commented 1 year ago

Hello.. I keep getting error "MTS\Common\Devices\Actions\Remote\Connections\Ssh::connectByUsernameFromLinux>> Not Handled for Request Type: connectByUsername" when i tried to connect SSH by username. Would you please help me?

merlinthemagic commented 1 year ago

Hi,

What are OS and SSH implementation are you connecting to?

Also MTS is not maintained, but MTM-SSH is.

MTM-SSH is far more stable, API is almost the same (see documentation), its Linux only, but given you are connecting from a Linux host that works. Try it,

mmsyamsurrijal commented 1 year ago

Hi, thanks for your response..

I've tried MTM-SSH and it works. Can I use this to connect to network router with various platform (ex: cisco, huawei, zte, nokia, etc)?

Because I've got error when I tried to get a remote shell on a linux server using an existing shell (using jumphost server to connect to network router). I got exception "Shell was terminated" on rawRead function when execute getDestinationShell.

merlinthemagic commented 1 year ago

Hi @mmsyamsurrijal,

MTM-SSH has 99% parity with the underlying shell. There are sometimes issues sending control sequences as they are non-printable. But generally I have not yet had an instance where it failed to connect to another linux box.

As for different routers and other network devices. Regarding the "Shell was terminated" error, chances are the shell type on the device you are connection to is unknown to MTM-SSH and it is likely you need to write a shell class for each type if they are not just a standard bash shell. This is because we need to establish what will act as a delimiter each time we build on the shell. If we dont have that we dont know if a command finished or if we should wait longer.

As an example see here for Mikrotik RouterOS.

In addition, once you connect a shell, the terminal you end up with might change (x-term, vt100 etc). Again see the mess of terminal breaks when parsing RouterOS returns.

Hats off to programs like Putty for handling all these cases as well as it does.

You can check the stdout piped data by starting a shell. inset a sleep(5), then execute the following on the command line:

tail -f /dev/shm/6*/stdOut

Then see the commands get executed and their return.