I am using libssh2 library to ssh connections in my mobile application. Here I want to use Agent Forwarding support.
I have followed same procedure as they have provided in example here LibSSH2 Agent Forwarding.
I am able to create agent successfully but when I try to connect it with libssh2_agent_connect(agent) It gives me error -39 LIBSSH2_ERROR_BAD_USE.
Well I am checking same thing using MAC OSX terminal and it's working fine. Please suggest if anything wrong,
This is how I am trying once do successful connection
struct libssh2_agent_publickey *identity, *prev_identity = NULL;
int rc;
agent = libssh2_agent_init(session);
if (!agent)
{
fprintf(stderr, "Failure initializing ssh-agent support\n");
rc = 1;
}
int temp=libssh2_agent_connect(agent);
if (temp)
{
fprintf(stderr, "Failure connecting to ssh-agent\n");
rc = 1;
}
Is there anything wrong here? please suggest.