[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


I am trying to make a simple connection to SFTP server using libssh0.9.5
with this program.

//https://api.libssh.org/master/libssh_tutor_sftp.html#sftp_read
#include <libssh/libssh.h>
#include <libssh/sftp.h>
#include <iostream>

using namespace std;

int main(){
    ssh_session sshs = ssh_new();
    if(sshs == NULL){
        cerr << "Error allocating SSH session: " << ssh_get_error(sshs) <<
endl;
        return SSH_ERROR;
    }
    //using hostname doesn't work either.
    ssh_options_set(sshs, SSH_OPTIONS_HOST, "192.168.2.15");
    ssh_options_set(sshs, SSH_OPTIONS_USER, "reach");

    //This is fine
    int rc = ssh_connect(sshs);
    if(rc != SSH_OK){
        cerr << "Error connecting to localhost: " << ssh_get_error(sshs) <<
endl;
        return SSH_ERROR;
    }

    //Error is here
    sftp_session sftps = sftp_new(sshs);
    if(sftps == NULL){
        cerr << "Error allocating SFTP session: " << ssh_get_error(sshs) <<
endl;
        return SSH_ERROR;
    }

    sftp_free(sftps);
    ssh_disconnect(sshs);
    ssh_free(sshs);
    return 0;
}

Above program prints `Error allocating SFTP session: sftp_new: Out of memory`
. I can connect to SFTP in reach@192.168.2.15 using other software. Can
somebody help me?

Follow-Ups:
Re:Jakub Jelen <jjelen@xxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org