Hello Jakub, Thanks a lot, I spent many hours yesterday looking about it. I asked it to chatgpt as well.
Jakub 1 - ChatGPT 0. Jose Bravo De: "Jakub Jelen" <jje...@redhat.com> Para: "libssh" <libssh@libssh.org> Enviados: Viernes, 14 de Abril 2023 7:36:21 Asunto: Re: Receiving and setting TERM env On 4/13/23 21:37, Jose David Bravo A wrote: > Hello, > > I implemented an SSH server using the example in ssh_server.c as a base. > > In the exec_pty function, I'm executing another program that uses ncurses. > > I believe I need to pass the client's TERM environment variable to the > PTY allocated to that client so that the ncurses program knows how to > display itself properly. Am I correct? > > How can I receive the TERM environment variable sent by the client and > set it in the allocated PTY? Correct. As you can see in the SSH specification, the TERM environment variable is passed as part of the SSH_MSG_CHANNEL_REQUEST of type "pty-req" so in your code you should find it in your ssh_message structure when you handle this message under msg->channel_request.TERM. https://www.rfc-editor.org/rfc/rfc4254#section-6.2 Regards, -- Jakub Jelen Crypto Team, Security Engineering Red Hat, Inc.