0
libssh를 사용하여 두 시스템 간의 연결을 수행하고 있으며 ssh 서버는 redhat이고 클라이언트는 CentOS입니다. 내 코드는 코드는 다음과 같습니다libssh를 사용하여 정의되지 않은 기호 오류
[1] libssh 0.5.5 (c) 2003-2010 Aris Adamantiadis ([email protected]) Distributed under the LGPL, please refer to COPYING file for information about your rights, using threading threads_noop
[2] Nonblocking connection socket: 4
[2] Socket connecting, now waiting for the callbacks to work
[1] Socket connection callback: 1 (0)
[1] SSH server banner: SSH-2.0-OpenSSH_5.3
[1] Analyzing banner: SSH-2.0-OpenSSH_5.3
[1] We are talking to an OpenSSH client version: 5.3 (50300)
[2] Received SSH_KEXDH_REPLY
[2] SSH_MSG_NEWKEYS sent
[2] Received SSH_MSG_NEWKEYS
./sshclient: symbol lookup error: ./sshclient: undefined symbol: ssh_pki_import_privkey_file
, 나는 문제의 무리가이 코드가 알고
int main()
{
ssh_session my_ssh_session;
ssh_key *pubkey,*privkey;
int verbosity = SSH_LOG_PROTOCOL;
int port = 5022,rc;
char username[20];
strcpy(username,"yoda"); //assigned a user name
my_ssh_session = ssh_new();
if (my_ssh_session == NULL)
exit(-1);
ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "XX.XX.XX.XX");
ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port);
ssh_options_set(my_ssh_session, SSH_OPTIONS_USER, username);
rc = ssh_connect(my_ssh_session);
if(rc != SSH_OK){
fprintf(stderr, "Error connecting to host: %s\n",ssh_get_error(my_ssh_session));
exit(-1);
}
rc = ssh_pki_import_privkey_file("/home/yoda/keys/id_rsa",NULL,NULL,NULL,privkey);
if(rc != SSH_OK){
fprintf(stderr, "Custom Message: Private Key unacceptable.\n");
exit(-1);
}
fprintf(stdout, "Custom Message: Here now.\n");
rc = ssh_userauth_publickey(my_ssh_session, NULL, *privkey);
if(rc == SSH_AUTH_ERROR){
fprintf(stderr, "Custom Message: A serious error has occured during authentication.\n");
exit(-1);
}
if(rc == SSH_AUTH_DENIED){
fprintf(stderr, "Custom Message: Unacceptable key or method.\n");
exit(-1);
}
if(rc == SSH_AUTH_PARTIAL){
fprintf(stderr, "Custom Message: Partially authenticated user.\n");
exit(-1);
}
ssh_key_free(*pubkey);
ssh_key_free(*privkey);
ssh_disconnect(my_ssh_session);
ssh_free(my_ssh_session);
return(0);
}
, 나는 이것을보고 계속 런타임에서 제외하고, 링크가 잘 컴파일하고 있지만, 이 시점에서 나는이 라이브러리를 처음으로 실험하고 있으며 작동시키려는 것에 더 관심이 있습니다. 무슨 일이 벌어지고 있는지에 대한 통찰력은 인정 될 것입니다.
고마워요, Rahul
이것은 컴파일 문제와 비슷해 보입니다. 코드를 컴파일하는 데 사용할 수있는 명령을 게시 할 수 있습니까? –
gcc -o sshclient sshRS.c -L/home/rs/libssh/lib -lssh -I/home/rs/libssh/include – RNS