Skip to content

SFTP: Cyberduck (sshj) connection dropped on initial REALPATH/STAT — server errors SshEncoding: length invalid #215

Description

@Yaminyam

Summary

Cyberduck (and likely other sshj/Java-based SFTP clients) cannot list any directory against bssh-server: right after the SFTP handshake, on the client's initial REALPATH + STAT of the home directory, the server drops the connection with:

Session error  error=SshEncoding: length invalid

The OpenSSH sftp CLI and FileZilla work fine against the exact same server, config, user, and directory — so this is specific to the request/response pattern that sshj-based clients use.

Client-side symptom (Cyberduck)

디렉터리 sion의 목록을 얻어오는데 실패하였습니다. (127.0.0.1 – SFTP)
Broken transport; encountered EOF. The connection attempt was rejected.
The server may be down, or your network may not be properly configured.

Server-side log (bssh-server run -vv)

INFO  bssh::server::handler: Starting SFTP session user=sion peer=127.0.0.1:54766 home=/Users/sion
DEBUG bssh::server::sftp: Creating SFTP handler user=sion chroot=None cwd=/Users/sion
INFO  bssh::server::sftp: SFTP session initialized user=sion version=3
DEBUG bssh_russh_sftp::protocol: packet type 16      # SSH_FXP_REALPATH
DEBUG bssh_russh_sftp::protocol: packet type 17      # SSH_FXP_STAT
DEBUG russh::server: Connection closed with error
DEBUG bssh_russh_sftp::server: sftp stream ended
ERROR bssh::server: Session error error=SshEncoding: length invalid

The connection dies immediately after the REALPATH (16) / STAT (17) exchange — before any OPENDIR/READDIR. So the server appears to mis-encode the REALPATH/STAT response (an SSH_FXP_NAME / SSH_FXP_ATTRS packet) such that the outgoing SSH channel-data length is invalid, and russh's transport encoder aborts the connection.

Repro

  1. bssh-server run -c config.yaml -D (no chroot: sftp.root unset; auth publickey or password; SFTP protocol v3 negotiated).
  2. Connect with Cyberduck (SFTP, 127.0.0.1, the configured user) → fails as above.
  3. Connect with OpenSSH sftp or FileZilla to the same server → works (list, get, put, rename, etc. all fine).

Impact

Many GUI/mobile SFTP clients are sshj/JSch-based (Cyberduck, and others). If they all hit this, bssh-server cannot be a drop-in SFTP endpoint for those clients.

Environment

  • bssh-server 2.2.3 (bssh-server-macos-aarch64)
  • SFTP protocol version 3
  • Failing client: Cyberduck (sshj); working clients: OpenSSH sftp, FileZilla

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions