[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Server Issue: Binding File Descriptors for STDIN_FILENO
[Thread Prev] | [Thread Next]
[Date Prev] | [Date Next]
- Subject: Server Issue: Binding File Descriptors for STDIN_FILENO
- From: Michael Griffin <mrmisticismo@xxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Tue, 2 Sep 2014 02:58:10 -0500
- To: "libssh@xxxxxxxxxx" <libssh@xxxxxxxxxx>
Hi, looking for a little advice or help. I'm using the latest SSHLib on ArchLinux and code::blocks for the IDE with gcc version 4.9.1. My issue is probably not related to my specs. I have a telnet daemon that i use from xinetd. -xinetd handles the connections and passes STDIN / STDOUT file descriptors to the telnet daemon. -the telnet daemon then handles all communications and or runs a shell. What I'm trying to do is handle SSH connections the same way. However, I'm finding it rather tricky because after a couple days of works I've gotten the connecting going. Key exchange, and Authorization within the session and channel_callbacks with SHELL and PTY requests recv and sent. The problem is that once the channel appears to be setup, once data from SSH_channel_read() or SSH_channel_write() I receive the following error message: Bad packet length 1016254014 ( <-- random number). Disconnecting: Packet corrupt The debug look like this: ================================================================== [merc@mandr4ke examples]$ ssh -v myuser@localhost OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to localhost [::1] port 22. debug1: connect to address ::1 port 22: Connection refused debug1: Connecting to localhost [127.0.0.1] port 22. debug1: Connection established. debug1: identity file /home/merc/.ssh/id_rsa type -1 debug1: identity file /home/merc/.ssh/id_rsa-cert type -1 debug1: identity file /home/merc/.ssh/id_dsa type -1 debug1: identity file /home/merc/.ssh/id_dsa-cert type -1 debug1: identity file /home/merc/.ssh/id_ecdsa type -1 debug1: identity file /home/merc/.ssh/id_ecdsa-cert type -1 debug1: identity file /home/merc/.ssh/id_ed25519 type -1 debug1: identity file /home/merc/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.6.1 debug1: ssh_exchange_identification: [2014/09/02 02:38:57.194283, 1] ssh_server_connection_callback: SSH client banner: SH-2.0-OpenSSH_6.6.1 debug1: ssh_exchange_identification: [2014/09/02 02:38:57.195406, 1] ssh_analyze_banner: Analyzing banner: SSH-2.0-OpenSH_6.6.1 debug1: ssh_exchange_identification: [2014/09/02 02:38:57.195668, 1] ssh_analyze_banner: We are talking to an OpenSSH clent version: 6.6 (60600) debug1: Remote protocol version 2.0, remote software version libssh-0.6.3 debug1: no match: libssh-0.6.3 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr hmac-sha1 none debug1: kex: client->server aes128-ctr hmac-sha1 none debug1: sending SSH2_MSG_KEX_ECDH_INIT debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: RSA f1:53:92:93:0a:76:ed:db:34:43:2a:9e:32:7d:8e:5d debug1: Host 'localhost' is known and matches the RSA host key. debug1: Found key in /home/merc/.SSH/known_hosts:1 debug1: SSH_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: gssapi-with-mic,password debug1: Next authentication method: password myuser@localhost's password: debug1: Authentication succeeded (password). Authenticated to localhost ([127.0.0.1]:22). debug1: channel 0: new [client-session] debug1: Entering interactive session. Bad packet length 1016254014. Disconnecting: Packet corrupt ================================================================== If I run the server examples: I took the basic code for this from samplesshd-cb.c with a couple slight differences. ================================================================== session = SSH_new(); sshbind = SSH_bind_new(); syslog(LOG_INFO, "SSH_bind_options_set "); // Bind the Address passed from Xinetd, the Port, and KEYS. SSH_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDADDR, hostaddr_string.c_str()); SSH_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDPORT, &port); SSH_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY, "SSH_host_dsa_key"); SSH_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, "SSH_host_rsa_key"); SSH_bind_options_set(sshbind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR, "1"); // Grab the File Descriptor passed from Xinetd r = SSH_bind_accept_fd(sshbind, session, STDIN_FILENO); if(r == SSH_ERROR) { syslog(LOG_INFO, "Testing - error SSH_bind_accept_fd."); _ent.errlog((char *)"Testing - error SSH_bind_accept_fd"); return 1; } ================================================================== The code works fine if I set this up as a stand alone server so I figure it has to do with the file descriptor which is strange. It works for all of the initial communication then dies on reading and writing to the channel. My question is - is this even possible to accomplish, or am I missing something that has to be done in this situation?
Archive administrator: postmaster@lists.cynapses.org