[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Creating a server
[Thread Prev] | [Thread Next]
- Subject: Re: Creating a server
- From: Andreas Schneider <asn@xxxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 13 Apr 2022 07:30:22 +0200
- To: libssh@xxxxxxxxxx
- Cc: Levente <leventelist@xxxxxxxxx>
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
Re: Creating a server | Levente <leventelist@xxxxxxxxx> |
Creating a server | Levente <leventelist@xxxxxxxxx> |