[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Create SSH server in Windows with libssh
[Thread Prev] | [Thread Next]
- Subject: Re: Create SSH server in Windows with libssh
- From: Alberto Garcia <agarciaillera@xxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Fri, 7 Dec 2018 13:58:05 -0800
- To: libssh@xxxxxxxxxx
I think I almost have it but I need the equivalent to `ssh_event_add_fd` but using windows `HANDLE` instead of `socket_t`. Is there something like that? Thank you On Fri, Dec 7, 2018 at 10:47 AM Alberto Garcia <agarciaillera@xxxxxxxxx> wrote: > Hi, > > I need to use libssh to create an SSH server that allows me to connect to > it and have a normal SSH session (executing commands in the SSH server, > autocomplete...). > > I've seen code in the examples folder to do that in Linux but nothing to > do so in windows. I've written some code that works fine creating a SSH > sever listening in a port, I create a new thread to handle every incoming > connection but I don't know how to follow to create a fully interactive > connection. > > The creation of the SSH server works fine but I don't know how to handle > the incoming connections to get a shell when logged in. > > Here is some code I've used: > > [...] > ssh_init(); > ssh_event event;/* Create and configure the ssh session. */auto sshbind = ssh_bind_new(); > ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDADDR, ip); > ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDPORT, &port); > ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, "C:\\Users\\user\\Desktop\\priv_key.txt"); > > /* Listen on `port' for connections. */if (ssh_bind_listen(sshbind) < 0) { > printf("Error listening to socket: %s\n", ssh_get_error(sshbind)); > return -1;}if (true) { printf("Listening on port %d.\n", port); } > /* Loop forever, waiting for and handling connection attempts. */while (1) { > > ssh_session session = ssh_new(); > if (ssh_bind_accept(sshbind, session) == SSH_ERROR) { > fprintf(stderr, "Error accepting a connection: %s'.\n", ssh_get_error(sshbind)); > return -1; > } > if (true) { printf("Accepted a connection.\n"); } > event = ssh_event_new(); > std::thread(sessionHandler, event, session).detach(); > > > But I need to properly implement the sessionHandler function > > Any help? > > Thanks > > -- > Alberto García Illera > > GPG Public Key <https://goo.gl/yshdwh> > -- Alberto García Illera GPG Public Key <https://goo.gl/yshdwh>
Re: Create SSH server in Windows with libssh | Andreas Schneider <asn@xxxxxxxxxxxxxx> |
Create SSH server in Windows with libssh | Alberto Garcia <agarciaillera@xxxxxxxxx> |