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

Re: Creating a server


On Wednesday, April 13, 2022 4:16:05 AM CEST Levente wrote:
> Hi,

Hey!

> 
> I am creating a server application, and I witness some strange thing.
> 
> I have this code snippet:
> 
>          if (ssh_bind_accept(sshbind, session) == SSH_OK) { /*This will
> block until a new connection created*/
>
> 
>              if (ssh_is_connected(session)) {
>                  debug(hm->dbg, DEBUG_INFO, "%s(): CLI: Session is
> connected.\n", __func__);
>              } else {
>                  debug(hm->dbg, DEBUG_INFO, "%s(): CLI: Session is not
> connected.\n", __func__);
>              }
> 
> ...
> 	}

The ssh session is marked as connected after a successful key exchange. 
Currently it is a connection from a client, but we don't know if it is a SSH 
client yet. ssh_handle_key_exchange(session) is needed first to check if we 
talk to a SSH client. But you should setup callbacks before you call 
ssh_handle_key_exchange()

Patches to improve the documentation are welcome! :-)

Did you look at examples/ssh_server.c? This is a simple ssh server 
implementation. We recommend to implement a pre-forking server for security 
reasons.


Best regards


	Andreas

-- 
Andreas Schneider                 asn@xxxxxxxxxxxxxx
GPG-ID:     8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D



Follow-Ups:
Re: Creating a serverLevente <leventelist@xxxxxxxxx>
References:
Creating a serverLevente <leventelist@xxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org