brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: scp -O brings back the old protocol when scp fails on an old SSH server

Network and access
~/tips/tip-scp-o-legacy-protocol

scp -O backup.tar user@old-router:/tmp/

Fix scp errors on routers and old servers that have no SFTP subsystem.

Since OpenSSH 9.0, scp uses the SFTP protocol under the hood. Mostly you never notice. On an old NAS, a router or a minimal embedded box without an SFTP server, it suddenly fails.

The fix is one capital letter:

scp -O backup.tar user@old-router:/tmp/

-O tells scp to use the legacy SCP protocol again. The man page names three reasons you might need it: the server has no SFTP, you rely on old wildcard behaviour, or you use paths with ~ on an older SFTP server.

The error that gives it away is usually something like subsystem request failed or a connection that closes right after login. If sftp user@host fails in the same way, the server has no SFTP and -O is your answer.

If you need it for one host all the time, a shell alias is the easy route, since there is no ssh_config option for it.

I’d only fall back to the old protocol when there is no other way. The switch to SFTP was made because the legacy protocol let the remote side influence how file names were expanded on your machine. With a server you control that is a small risk, but I would not use -O against a box I do not trust.

Further reading: scp man page, OpenSSH 9.0 release notes

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link