Skip to content
Contents
GuidesOpenWrt

Can an OpenWrt SSH banner end up in a copied file? Test four bytes first

Before repeating a large transfer, send GM42. A greeting visible in the terminal may never reach the destination file.

Before repeating a large transfer, send GM42. A greeting visible in the terminal may never reach the destination file.

Where the two greetings come from

Run these read-only checks on the router. The screenshots show an isolated OpenWrt 25.12.6 x86/64 VM. Dropbear can send BannerFile before authentication. An interactive login shell can later display /etc/banner through /etc/profile.

grep /etc/banner /etc/profile
grep BannerFile /etc/init.d/dropbear
uci show dropbear

OpenWrt 25.12.6 · SSH · /etc/profile · BannerFile

We temporarily used two different LAB notices. The first connection deliberately offered no credentials and saw the first notice before rejection. Only the successful login showed the second. You can run the checks without changing either notice or failing a login.

OpenWrt 25.12.6 · SSH · Dropbear · LAB

Separate the streams on your computer

Use a fresh empty directory on a Linux computer. Redirection overwrites existing files. Replace lab-router with your SSH alias or user and host after verifying the host key. OpenSSH -T avoids a pseudo-terminal. Keep 2>&1 out of the transfer.

ssh -T lab-router 'printf GM42' >payload 2>messages
echo "exit=$?"
wc -c <payload
od -An -tx1 payload
cat messages

The lab returned exit 0 and exactly four bytes in payload, 47 4d 34 32 in hex. The notice went to messages. On a nonzero exit read the error first, even if the file exists. Next compare hashes with this small file.

ssh -T lab-router 'sha256sum /etc/openwrt_release'
ssh -T lab-router 'cat /etc/openwrt_release' >copy 2>log
echo "exit=$?"
sha256sum copy

OpenWrt 25.12.6 · SSH · stdout · stderr · SHA256

When to retry the transfer

If extra bytes appear, inspect the remote command, wrappers and startup output. Restrict greetings to interactive use. The -T flag cannot silence a script writing to stdout. Back up first and keep another admin path. If you changed a banner, restore the original file and instance settings, restart the service if needed and reconnect. Compare both SHA256 values on an unchanged source before using the copy. Never trim a fixed number of lines from a binary.

OpenWrt 25.12.6 · SSH · banner-restored · config-restored

What does an OpenWrt configuration backup restore?

Explore hardware

Comments