Skip to content

WinSCP SCP mode / terminal fails: /etc/profile runs BusyBox resize on non-tty SSH logins #142

Description

@mcfbytes

Report

From the forum thread Buildroot MiSTer Announcement, post by DoubleA (2026-09-03):

Finally some love for the underlying OS, thanks for that.
But had to switch back, because the current version v2026.09.02-beta didn't allow me to open a bash window (via WinSCP, Putty was OK).
What did i do wrong?

Reproduced locally on release 260902: WinSCP's SCP protocol mode and its Open Terminal window both fail with

Error skipping startup message. Your shell is probably incompatible with the application (BASH is recommended).

SFTP, FTP, PuTTY and command-line ssh/scp all work.

Root cause

/etc/profile (rootfs overlay) ends with resize >/dev/null, copied verbatim from stock. resize is the BusyBox applet. It writes a cursor-position query (ESC 7 ESC [r ESC [999;999H ESC [6n) to stderr and then reads the terminal's reply from stdin with scanf under a 3 s alarm.

WinSCP drives the login shell without a pseudo-terminal. Nothing answers the query, so:

  • the escape bytes land on WinSCP's stderr channel before any prompt, and
  • WinSCP's first command is consumed by resize as the supposed reply.

Verified byte-for-byte with ssh -T root@mister.lan (no pty) and feeding two commands: the escape sequence arrives, the first command vanishes, only the second echoes back.

PuTTY works because a real terminal emulator answers the query.

Stock has the same defect

Checked against the stock release_20250402 linux.img: identical /etc/profile line, /usr/bin/resize -> busybox (1.33.1). Running stock's own armhf busybox under qemu-arm on a pty emits the identical bytes and swallows the next line of input. So this is inherited, not a regression introduced by this project, but it is worth fixing here.

Fix

Run resize only where it can do anything useful: an interactive shell that is not an SSH session (i.e. the serial console, where nothing else reports the window size). Over SSH the client already propagates window size through the pty.

[ "$PS1" ] && [ -z "$SSH_CONNECTION" ] && resize >/dev/null

SSH_CONNECTION is set by sshd for every session, pty or not (SSH_TTY is not, which is why a first attempt using it did not help). Applied live on a test board and verified: no-pty login shell, pty login shell and bash -l are all clean; a simulated serial console still runs resize.

This is a deliberate one-line deviation from stock's /etc/profile; docs/init-parity.md needs a matching row update.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions