我正在使用libssh庫並嘗試創建新的SFTP會話。我不斷收到的SFTP libssh失敗
ssh_packet_unimplemented: Received SSH_MSG_UNIMPLEMENTED (sequence number 3)
的錯誤消息我檢查遠程服務器的系統日誌,發現錯誤
dispatch_protocol_error: type 90 seq 3 [preauth]
出於某種原因,我在嘗試使用以下(取自此錯誤時libssh doc)
int sftp_helloworld(ssh_session session) {
sftp_session sftp;
int rc;
sftp = sftp_new(session); // Freezes at this part
if (sftp == NULL) {
fprintf(stderr, "Error allocating SFTP session: %s\n", ssh_get_error(session));
return SSH_ERROR;
}
rc = sftp_init(sftp);
if (rc != SSH_OK) {
fprintf(stderr, "Error initializing SFTP session: %s.\n", sftp_get_error(sftp));
sftp_free(sftp);
return rc;
}
sftp_free(sftp);
return SSH_OK;
}
是工作的唯一的事情是實際ssh連接。無論我使用SCP,SFTP還是打開遠程外殼,都會發生同樣的錯誤。
我已經研究了很多關於我的問題,但找不到任何補救措施。任何幫助都會很棒。
編輯:
在我通過/var/log/auth.log
看了一下,發現這個在Amazon EC2服務器:
sshd[24860]: Accepted publickey for ubuntu
sshd[24860]: pam_unix(sshd:session): session opened for user ubuntu by (uid=0)
sshd[24930]: dispatch_protocol_error: type 90 seq 3 [preauth]
在我設定的SSH_OPTIONS_LOG_VERBOSITY
到SSH_LOG_PACKET
,一切順利的libssh代碼,但是當它得到sftp_new()
我收到這個錯誤,它凍結在SSH_MSG_UNIMPLEMENTED
消息,
channel_open: Creating a channel 43 with 64000 window and 32768 max packet
packet_send2: packet: wrote [len=44,padding=19,comp=24,payload=24]
channel_open: Sent a SSH_MSG_CHANNEL_OPEN type session for channel 43
ssh_socket_unbuffered_write: Enabling POLLOUT for socket
ssh_packet_socket_callback: packet: read type 3 [len=12,padding=6,comp=5,payload=5]
ssh_packet_process: Dispatching handler for packet type 3
ssh_packet_unimplemented: Received SSH_MSG_UNIMPLEMENTED (sequence number 3)
EDIT2:
我用下面的代碼來連接到服務器,
ssh_key pKey;
int rc = ssh_pki_import_privkey_file(PC_PRIVATE_KEY_FILE, NULL, NULL, NULL, &pKey);
ssh_session my_ssh_session = ssh_new();
ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, PC_HOST);
ssh_options_set(my_ssh_session, SSH_OPTIONS_USER, PC_USER);
ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &PC_PORT);
ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &PC_VERBOSITY);
rc = ssh_connect(my_ssh_session);
我由tutorial混淆。我可能沒有編寫代碼來正確連接到服務器。
您可以連接到使用常規SFTP客戶端服務器,在所有? –
@MartinPrikryl是的,我可以使用'ssh','sftp'和'scp'連接到服務器。 – Amous
收集您可以編輯的所有日誌,並將其編輯到您的問題中。服務器端日誌(無論如何SSH服務器?),'sftp -vv'輸出,libssh日誌。 –