diff --git a/examples/scpclient/scpclient.c b/examples/scpclient/scpclient.c index c0cc7602b..1392b2006 100644 --- a/examples/scpclient/scpclient.c +++ b/examples/scpclient/scpclient.c @@ -253,13 +253,13 @@ THREAD_RETURN WOLFSSH_THREAD scp_client(void* args) #endif /* WOLFSSH_CERTS */ wolfSSH_CTX_SetPublicKeyCheck(ctx, ClientPublicKeyCheck); - wolfSSH_SetPublicKeyCheckCtx(ssh, (void*)host); - ssh = wolfSSH_new(ctx); if (ssh == NULL) err_sys("Couldn't create wolfSSH session."); + wolfSSH_SetPublicKeyCheckCtx(ssh, (void*)host); + if (password != NULL) wolfSSH_SetUserAuthCtx(ssh, (void*)password);