I am using the libssh library and trying to create a new SFTP session. I keep getting an error message of
ssh_packet_unimplemented: Received SSH_MSG_UNIMPLEMENTED (sequence number 3)
I checked the syslog of the remote server and found the error
dispatch_protocol_error: type 90 seq 3 [preauth]
For some reason I get this error when trying to use the following (taken from the 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;
}
The only thing that is working is the actual ssh connection. The same error occurs whether I'm using SCP, SFTP or when opening a remote shell.
I've researched a lot regarding my issue, but couldn't find any remedies. Any help would be great.
EDIT:
On the Amazon EC2 server I looked through /var/log/auth.log
and found this:
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]
In the libssh code I set the SSH_OPTIONS_LOG_VERBOSITY
to SSH_LOG_PACKET
, everything runs smoothly, but when it gets to the sftp_new()
I recieve this error and it freezes at the SSH_MSG_UNIMPLEMENTED
message,
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:
I used the following code to connect to the server,
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);
I was confused by the tutorial. I might have not wrote the code to connect to the server properly.