[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keep alive the session after remote execution of the commands


Hi Andreas,

On Fri, Jul 1, 2022 at 11:51 AM Javad Rahimi <javad321javad@xxxxxxxxx>
wrote:

> Hi Andreas,
> Thank you very much
> I will test it .
>
> Best regards,
> Javad
>
> On Fri, Jul 1, 2022, 11:20 Andreas Schneider <asn@xxxxxxxxxxxxxx> wrote:
>
>> On Thursday, June 30, 2022 10:42:59 AM CEST Javad Rahimi wrote:
>> > Hello,
>>
>> Hi,
>>
>> > We have developed a simple ssh client application based on this
>> > <https://api.libssh.org/stable/libssh_tutor_command.html> example
>> (libssh:
>> > Chapter 4) to run a command remotely and return the results. However,
>> the
>> > ssh server disconnects the connection after executing the command and
>> > returning the result.
>> > However, it doesn't happen for all SSH servers.
>> > Is there any way to force the ssh server to keep alive the session after
>> > executing
>>
>> It is normal that the session gets closed after an exec request (see the
>> RFC).
>> If you don't want that use a non-interactive shell ...
>>
>> https://api.libssh.org/stable/libssh_tutor_shell.html
>>
>> There is no example, but you could improve the docs once you get it
>> working!
>>
>> You need to use ssh_channel_request_shell() and you need some protocol to
>> find
>> out if your command was successful or not like:
>>
>> ./mytool && echo SSH_OK || echo SSH_KO
>>
>> I have tried this approach, but it doesn't works for us. We need to
execute the commands remotely and get the result. But not in a remote
shell. Only one device shows such problems. Other SSH server keep the
session alive. Here is the dump data after executing a command.
[2022/07/01 12:45:32.185970, 1] ssh_packet_disconnect_callback:  Received
SSH_MSG_DISCONNECT: 11:Bye Bye
[2022/07/01 12:45:32.186041, 1] ssh_socket_exception_callback:  Socket
exception callback: 2 (2)
[2022/07/01 12:45:32.186052, 1] ssh_socket_exception_callback:  Socket
error: No such file or directory
[2022/07/01 12:45:32.186065, 1] ssh_socket_exception_callback:  Socket
exception callback: 2 (2)
[2022/07/01 12:45:32.186071, 1] ssh_socket_exception_callback:  Socket
error: No such file or directory
command: p
[2022/07/01 12:45:38.121765, 2] channel_open:  Creating a channel 44 with
64000 window and 32768 max packet
[2022/07/01 12:45:38.121825, 1] ssh_socket_exception_callback:  Socket
exception callback: 2 (2)
[2022/07/01 12:45:38.121836, 1] ssh_socket_exception_callback:  Socket
error: No such file or directory

Best Regards,
Javad

>
>> I hope this helps :-)
>>
>>
>>         Andreas
>>
>> --
>> Andreas Schneider                 asn@xxxxxxxxxxxxxx
>> GPG-ID:     8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D
>>
>>
>>

References:
Re: Keep alive the session after remote execution of the commandsAndreas Schneider <asn@xxxxxxxxxxxxxx>
Re: Keep alive the session after remote execution of the commandsJavad Rahimi <javad321javad@xxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org