I'm try to use libssh2 to write a string to a file. And I can do it.
The problem is I only can write once to the file, I can't append to the file, and giving the arguments to the libssh2_scp_send
I give the size, if the size is bigger then the real size of the string (ex. I give 50, but the string have 5 chars) the is created but with 0 bytes.
function I use:
int s7c_hardware::writeKey(char * filename, char * str)
{
channel = libssh2_scp_send(session, filename, 0777, strlen(str));
char buf[99999];
memcpy(buf, str, strlen(str));
buf[strlen(str)] = '\0';
libssh2_channel_write(channel, buf, strlen(str));
libssh2_channel_free(channel);
channel = NULL;
return 0;
}