[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: Levente <leventelist@xxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Fri, 15 Apr 2022 14:31:00 +0200
- To: Andreas Schneider <asn@xxxxxxxxxxxxxx>, libssh@xxxxxxxxxx
Hi Andreas, Thanks for your answer! Please find my comments and further below. On 4/13/22 07:30, Andreas Schneider wrote:
The ssh session is marked as connected after a successful key exchange.
Okay, that explains a lot of things, however, I still don't know why I get 'Socket error: disconnected' message. This suggests that even the socket is not connected.
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()
Yes, this is the failing call. I add the callbacks as follows: struct ssh_channel_callbacks_struct channel_cb = { .userdata = &cdata, .channel_pty_request_function = cli_pty_request, // .channel_pty_window_change_function = pty_resize, .channel_shell_request_function = cli_shell_request, // .channel_exec_request_function = exec_request, // .channel_data_function = data_function, // .channel_subsystem_request_function = subsystem_request }; struct ssh_server_callbacks_struct server_cb = { .userdata = &sdata, .auth_password_function = cli_auth_password, .channel_open_request_session_function = cli_channel_open };ssh_set_auth_methods(session, SSH_AUTH_METHOD_PASSWORD); /*we could support for key type authentication, but password is enough for now.*/
ssh_callbacks_init(&server_cb); ssh_callbacks_init(&channel_cb); ret = ssh_set_server_callbacks(session, &server_cb); if (ret != SSH_OK) {debug(hm->dbg, DEBUG_ERR, "%s(): CLI: Error setting server callbacks.\n", __func__);
ret_val = ERR; goto exit_point; } I don't know for sure if it is okay to have just the un-commented callbacks.
Patches to improve the documentation are welcome!:-)
I can contribute. Can you tell me which repository contains the documents, and how to submit PRs?
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.
Yes, I'm following that example code. BR, Levente -- Levente Kovacs Senior Electronic Engineer W: http://levente.logonex.eu
Creating a server | Levente <leventelist@xxxxxxxxx> |
Re: Creating a server | Andreas Schneider <asn@xxxxxxxxxxxxxx> |