[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: ssh_channel_request_exec is Failing, returning -1.
[Thread Prev] | [Thread Next]
- Subject: RE: ssh_channel_request_exec is Failing, returning -1.
- From: "V Sidnal, Nagraju" <nagraju.sidnal@xxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Tue, 23 Jun 2020 15:47:59 +0000
- To: "libssh@xxxxxxxxxx" <libssh@xxxxxxxxxx>, Jakub Jelen <jjelen@xxxxxxxxxx>
Hi Jakub, Thanks a lot for your inputs. You are absolutely correct, ssh_channel_request_exec will not work with ssh_channel_request_shell. Now I'm trying with ssh_channel_write(channel, command, command.length()) to execute command on server. Use of this API(ssh_channel_write) is very complex and & does not look that good. If we can come up with something like ssh_channel_request_exec , would be of great addition to Libssh. Regards, Nagraju -----Original Message----- From: Jakub Jelen <jjelen@xxxxxxxxxx> Sent: Monday, June 22, 2020 3:56 PM To: libssh@xxxxxxxxxx Subject: Re: ssh_channel_request_exec is Failing, returning -1. On Mon, 2020-06-22 at 05:18 +0000, V Sidnal, Nagraju wrote: > Hi Jakub, > > I tried same with Default SSH server running on Debain 9. However it > still failed.. > channel = ssh_channel_new(my_ssh_session); rc = > ssh_channel_open_session(channel); > rc = ssh_channel_request_pty(channel); rc = > ssh_channel_request_shell(channel); > rc = ssh_channel_request_exec(channel, command.c_str()); If you open shell already, request_exec is no longer possible in that particular channel. At that point, the shell is already running in the server and you can run commands there by sending data to it and reading data as described in tutorial: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapi.libssh.org%2Fstable%2Flibssh_tutor_shell.html&data=02%7C01%7Cnagraju.sidnal%40siemens.com%7C7a79d7d08f764027d8c008d816987b32%7C38ae3bcd95794fd4addab42e1495d55a%7C1%7C0%7C637284191441644474&sdata=jdj%2Fh2%2FLNiBr28Qd8%2F6e%2FQIhJRXcM3aRej89jusmtHE%3D&reserved=0 If I read the logs right, device does not allow you to exec command directly, but allows only shell access. Hope it helps, -- Jakub Jelen Senior Software Engineer Security Technologies Red Hat, Inc.
ssh_channel_request_exec is Failing, returning -1. | "V Sidnal, Nagraju" <nagraju.sidnal@xxxxxxxxxxx> |
Re: ssh_channel_request_exec is Failing, returning -1. | Jakub Jelen <jjelen@xxxxxxxxxx> |
RE: ssh_channel_request_exec is Failing, returning -1. | "V Sidnal, Nagraju" <nagraju.sidnal@xxxxxxxxxxx> |
Re: ssh_channel_request_exec is Failing, returning -1. | Jakub Jelen <jjelen@xxxxxxxxxx> |