[Libssh] Implementing a SSH server

Aris Adamantiadis aris at 0xbadc0de.be
Tue Dec 30 03:43:55 CET 2008


Hello,

after reading server.c source, it seems that what you want to do is not
possible using only the external API. So I understand why you got out
some code from ssh_bind_accept() into your own code.
Your code has the two lines:
    session->dsa_key = dsa;
    session->rsa_key = rsa;
How did you define the variables dsa and rsa ? You will have to set them
as explained in ssh_bind_accept().

It's really ugly but it might work as expected.
Something possible would be changing your app a little to use
ssh_bind_accept by giving it a file descriptor in the to-be-accepted state.

I agree it lacks a function like
ssh_accept_fd(SSH_OPTIONS options, int fd);

Maybe in 0.3

Regards,

Aris

Jan Willamowius a écrit :
> Hi,
> 
> I'm trying to use libssh to replace a telent server in a C++ application
> with a ssh server. I'm sticking as close to the samplesshd as I can,
> but I have to pass in the file descriptor for the socket.
> 
> When running under valgrind, I can see that my code throws a lot of
> errors in ssh_accept() about crypto variables not being initialized,
> while samplesshd doesn't.
> 
> My code looks like this:
> 
>     session = ssh_new();
>     session->server = 1;
>     session->version = 2;
>     SSH_OPTIONS *options = ssh_options_new();
>     ssh_options_set_dsa_server_key(options, "ssh_host_dsa_key");
>     ssh_options_set_rsa_server_key(options, "ssh_host_rsa_key");
>     // ... read keys ...
>     ssh_socket_free(session->socket);
>     session->socket = ssh_socket_new(session);
>     ssh_socket_set_fd(session->socket, NEW_HANDLE);
>     ssh_options_set_fd(options, NEW_HANDLE);
>     ssh_set_options(session, options);
>     session->dsa_key = dsa;
>     session->rsa_key = rsa;
> 
>     if(ssh_accept(session)) {
> 	return false;
>     }
> 
> What else do i need to initialize before calling ssh_accept() ?
> 
> Thanks,
> Jan
> 



More information about the Libssh mailing list