title: Ruby SFTP returns "Net::SSH::Disconnect: disconnected: Failed to read binary packet data! (2)"
body: <p>I have this in ruby 1.9.3:</p>
  
  <pre><code>Net::SFTP.start(ENV['SFTP_HOST'], ENV['SFTP_USERNAME'], password: ENV['SFTP_PASSWORD'], key_data: [ENV['SFTP_KEY']], keys_only: true) do |sftp|
    sftp.upload!(StringIO.new("testing"), "/text.txt")
  end
  </code></pre>
  
  <p>It appears to do the authentication step correctly (I can list files in a directory etc) but when I do the <code>upload!</code> command like above it returns:</p>
  
  <pre><code>Net::SSH::Disconnect: disconnected: Failed to read binary packet data! (2)
  from /Users/barmstrong/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/net-ssh-2.5.2/lib/net/ssh/transport/session.rb:176:in `block in poll_message'
  from /Users/barmstrong/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/net-ssh-2.5.2/lib/net/ssh/transport/session.rb:166:in `loop'
  from /Users/barmstrong/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/net-ssh-2.5.2/lib/net/ssh/transport/session.rb:166:in `poll_message'
  from /Users/barmstrong/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/net-ssh-2.5.2/lib/net/ssh/connection/session.rb:451:in `dispatch_incoming_packets'
  from /Users/barmstrong/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/net-ssh-2.5.2/lib/net/ssh/connection/session.rb:213:in `preprocess'
  from /Users/barmstrong/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/net-ssh-2.5.2/lib/net/ssh/connection/session.rb:197:in `process'
  from /Users/barmstrong/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/net-ssh-2.5.2/lib/net/ssh/connection/session.rb:161:in `block in loop'
  from /Users/barmstrong/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/net-ssh-2.5.2/lib/net/ssh/connection/session.rb:161:in `loop'
  from /Users/barmstrong/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/net-ssh-2.5.2/lib/net/ssh/connection/session.rb:161:in `loop'
  from /Users/barmstrong/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:802:in `loop'
  from /Users/barmstrong/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/net-sftp-2.0.5/lib/net/sftp/operations/upload.rb:195:in `wait'
  from /Users/barmstrong/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:103:in `upload!'
  </code></pre>
  
  <p>I also tried</p>
  
  <pre><code>    # open and write to a pseudo-IO for a remote file
      sftp.file.open("/test.txt", "wb") do |f|
        f.puts "testing"
      end
  </code></pre>
  
  <p>To try writing a binary file, but no luck.</p>
  
  <p>Any ideas?  Thanks!</p>