crypto/ssh - Read() blocking forever

238 views
Skip to first unread message

snore...@gmail.com

unread,
Apr 28, 2013, 2:15:20 PM4/28/13
to golan...@googlegroups.com
Hello,

I wanted to implement the SFTP protocol, using the ssh package from code.google.com/p/go.crypto/ssh. Problem is that after "con.Handshake()" -> "channel := con.Accept()" -> "channel.Accept()" everything stands still. I am trying to make a channel.Read() but that blocks forever.

From a user's perspective: after connecting to the go ssh server and logging in successfully the only way to close the connection is by shutting down the server.

Can you give me any hints, how to send/receive packets?

Daniel Theophanes

unread,
Apr 28, 2013, 2:53:10 PM4/28/13
to golan...@googlegroups.com
You could try to use the following as an example:

As a side note, I will be making an update to that package, in a not too distant future.

snore...@gmail.com

unread,
Apr 28, 2013, 4:13:07 PM4/28/13
to golan...@googlegroups.com
By looking at the code it seems as you do exactly the same right up to the "channel.Read(b)" part - and that's where my program hangs. I'm checking for a returning error, and I have a Println() directly after the read - it never get's there.
I'm connecting to the server via the openssh client and Filezilla (SFTP). Filezilla says connection timeout, and the openssh client just doesn't respond anymore.

I tested your program (I set "config.NoClientAuth = true") and Read() works here - I can't see any difference though.. Have to check everything line by line tomorrow...

Daniel Theophanes

unread,
Apr 28, 2013, 4:17:21 PM4/28/13
to snore...@gmail.com, golan...@googlegroups.com

Verify you are using a new goroutine for several calls. Point to the sec if you want help.

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/Hu23HdduOK8/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

snore...@gmail.com

unread,
Apr 28, 2013, 4:28:20 PM4/28/13
to golan...@googlegroups.com, snore...@gmail.com
Good point! My Read() was not inside an extra Go routine, now it is and it is working - thank you!

But why does it have to be?

Daniel Theophanes

unread,
Apr 28, 2013, 4:34:30 PM4/28/13
to snore...@gmail.com, golang-nuts
The Accept call must still process the packets on the connection. It
must decode, buffer, and then if the packet is a data packet, send
them on to the Read buffer. Thus you are actually doing several things
in the SSH server: 1) Accepting new connections. 2) Maintaining
accepted connections and processing packets 3) Reading and writing to
connection. Each must be done without blocking the others.

Dennis Francis

unread,
Jul 6, 2013, 1:21:30 AM7/6/13
to golan...@googlegroups.com
Hello,

Would you opensource your sftp implementation ?  I am in need of an sftp package for a project.

Thanks in advance,
Dennis
Reply all
Reply to author
Forward
0 new messages