[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re:
[Thread Prev] | [Thread Next]
[Date Prev] | [Date Next]
- Subject: Re:
- From: Jakub Jelen <jjelen@xxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 30 Jun 2021 09:16:05 +0200
- To: libssh@xxxxxxxxxx
Hi, yourhe above code has couple of issues including the missing hostkey verification and authentication. Both of these need to be completed before opening a sftp session as discussed in the first part of the tutorial https://api.libssh.org/master/libssh_tutor_guided_tour.html I assume this boils down to this hard-to-parse error. I assume it would be more useful if we would have better error message in this case. I assume the failing function here is ssh_channel_new(). In any case, adding more verbosity might point you to the right place. Regards, Jakub On Wed, Jun 30, 2021 at 6:37 AM Achmad Fathoni <fathoni.id@xxxxxxxxx> wrote: > 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? > >
[no subject] | Achmad Fathoni <fathoni.id@xxxxxxxxx> |