Discussion:
ssh protocol flow diagram
suyog jadhav
2011-04-09 07:12:52 UTC
Permalink
Hi,

I am trying to develop an ssh/scp client using libssh2.
I would like to know if there are any flow diagram available for ssh protocol.
I had developed a voip client in the past and following rfc with detailed flow
diagram for SIP protocol proved very helpful.
http://www.faqs.org/rfcs/rfc3665.html.

I have searched on net but only found this,
Loading Image...


Even after reading ssh RFC,I am having confusion in the flow for closing the
channel e.g. which party is supposed to send EOF, is it mandatory to send/recv
EOF before closing.

I am facing specific trouble while sending file via scp, due to the EOF
dilemma,as even though the file is sent to the remote host,and size is shown
correct, the checksum doesn't match.
When libssh2_channel_write returns 0, what does it mean and how to handle it.
Thanks in advance for your help

Regards
Suyog
Daniel Stenberg
2011-04-09 08:38:29 UTC
Permalink
I am trying to develop an ssh/scp client using libssh2. I would like to know
if there are any flow diagram available for ssh protocol.
Hi!

While such a flow diagram would be awesome, I don't think an application that
uses libssh2 will or should need any such. We provide and document an API to
use and that's what should be described and understood.

The SSH protocol details underneath should be more left for those of us who
acutally fiddles with libssh2 itself.
I am facing specific trouble while sending file via scp, due to the EOF
dilemma,as even though the file is sent to the remote host,and size is shown
correct, the checksum doesn't match.
Did you follow an example? Or can you even show us your code that uses
libssh2?
When libssh2_channel_write returns 0, what does it mean and how to handle it.
It means that no payload data was sent and you should keep sending. Is this
with the API in blocking or non-blocking mode?
--
/ daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
suyog jadhav
2011-04-11 03:52:17 UTC
Permalink
Hi,

In the example scp_write_nonblock.c

do { while ((rc = libssh2_channel_write(channel, ptr,
nread)) == LIBSSH2_ERROR_EAGAIN) {
waitsocket(sock, session); prev = 0; }
if (rc < 0) { fprintf(stderr, "ERROR %d total %ld / %d prev
%d\n", rc, total, (int)nread, (int)prev);
break; } else { prev = nread;
if(rc > nread) { fprintf(stderr, "MOO %d > %d\n", (int)rc,
(int)nread); } /* rc indicates how many bytes were written this
time */ nread -= rc; ptr += rc; }
} while (nread);
In what case, this condition would occur (rc > nread), is it error ,if yes how
should it be handled, becoz I am getting this (rc > nread) in some cases and
after that libssh2_channel_write always returns 0, eventually hanging the
process.

Regards
suyog



________________________________
From: "libssh2-devel-request-***@public.gmane.org" <libssh2-devel-request-***@public.gmane.org>
To: libssh2-devel-***@public.gmane.org
Sent: Sun, 10 April, 2011 3:30:03 PM
Subject: libssh2-devel Digest, Vol 23, Issue 6

Note: Forwarded message is attached.

Send libssh2-devel mailing list submissions to
libssh2-devel-***@public.gmane.org

To subscribe or unsubscribe via the World Wide Web, visit
http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
or, via email, send a message with subject or body 'help' to
libssh2-devel-request-***@public.gmane.org

You can reach the person managing the list at
libssh2-devel-owner-***@public.gmane.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of libssh2-devel digest..."
Today's Topics:

1. Re: ssh protocol flow diagram (Daniel Stenberg) (suyog jadhav)
2. Keyboard Interactive (Robert M. M?nch)
3. Re: Keyboard Interactive (Peter Stuge)
Daniel Stenberg
2011-04-11 06:50:02 UTC
Permalink
On Mon, 11 Apr 2011, suyog jadhav wrote:

The detail I said about NOT using the mailing list in digest mode when trying
to have a conversation was not a joke. We cannot have this discussion if
you're going to totally destroy both threading and quoting in every mail you
send here.

Also, I did ask you questions about version and platform that I consider vital
for this issue.
I am getting this (rc > nread) in some cases and after that
libssh2_channel_write always returns 0, eventually hanging the process.
A hang would indicate a bug somewhere.
--
/ daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
suyog jadhav
2011-04-12 07:57:29 UTC
Permalink
Hi,

I am extremely sorry for the mess because of digest.
I receive the mails in digest and replied to it.(I hope current reply is in correct format).
I am using libssh2 1.2.4 version on RHEL 5.3 platform and recently using 1.2.7/8 to verify.

I have been able to solve the issue. It was mistake in my code which didn't handle partial writes(in case of window adjust)
If libssh2_channel_write wrote only partial of what was asked, I was looping the same buffer as the previous instead of incrementing pointer by the size of written bytes.

However as previously asked,I would like to understand following excerpt from scp_write_nonblock.c

rc = libssh2_channel_write(channel, ptr, nread);
                if(rc > nread) {
                    fprintf(stderr, "MOO %d > %d\n", (int)rc, (int)nread);
                }
In what scenarios rc would be greater than nread, is it error condition(MOO??), if yes how to handle it.

While I understand your point about the ssh flow diagram not being absolute must for client developers, but it would certainly  improve the understanding/knowledge while writing application and to participate in libssh2 development as well. So if anyone has such information please share it.

Thanks a lot for your patience and support.
Suyog

From: Daniel Stenberg <daniel-7AX/***@public.gmane.org>
To: libssh2 development <libssh2-devel-***@public.gmane.org>
Sent: Monday, 11 April 2011 12:20 PM
Subject: Re: ssh protocol flow diagram

The detail I said about NOT using the mailing list in digest mode when trying to have a conversation was not a joke. We cannot have this discussion if you're going to totally destroy both threading and quoting in every mail you send here.

Also, I did ask you questions about version and platform that I consider vital for this issue.
I am getting this (rc > nread) in some cases and after that libssh2_channel_write always returns 0, eventually hanging the process.
A hang would indicate a bug somewhere.

-- 
/ daniel.haxx.se
Daniel Stenberg
2011-04-12 08:47:11 UTC
Permalink
Post by suyog jadhav
I am using libssh2 1.2.4 version on RHEL 5.3 platform and recently using 1.2.7/8 to verify.
Great. 1.2.4 is rather old and we've fixed plenty bugs since that.
Post by suyog jadhav
However as previously asked,I would like to understand following excerpt
from scp_write_nonblock.c
rc = libssh2_channel_write(channel, ptr, nread);
                if(rc > nread) {
                    fprintf(stderr, "MOO %d > %d\n", (int)rc, (int)nread);
                }
In what scenarios rc would be greater than nread, is it error
condition(MOO??), if yes how to handle it.
It can't happen. If it ever happens it would indicate a serious libssh2 bug.
I don't remember why the example code has that check, but I hve removed it
now!
--
/ daniel.haxx.se
Continue reading on narkive:
Loading...