[Libssh] Implementing a SSH server

Jan Willamowius jan at willamowius.de
Mon Dec 29 13:43:24 CET 2008


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

-- 
Jan Willamowius, jan at willamowius.de, http://www.willamowius.de/



More information about the Libssh mailing list