disabling local-to-local transfers?

Damien Miller djm at mindrot.org
Sat Jul 25 11:05:45 AEST 2026


On Fri, 24 Jul 2026, Jim Knoble wrote:

> 
> > On Jul 24, 2026, at 10:34, Samuel Thibault <samuel.thibault at ens-lyon.org> wrote:
> > 
> > [...]
> > No, you don't want "smart" tools which try to guess what you actually
> > meant, and sometimes get thing wrong and fail horribly.
> 
> You miss my point. Write your own script to do what you want. The feature to detect your mistake (as Theo has pointed out) doesn't belong in scp.

Here you go:

scp() {
	local _answer=""
	local _flagsdone=""
	local _remote=""
	for av in "$@" ; do
		if test -z "$_flagsdone" ; then
			case "$av" in
			-*) continue ;;
			*) _flagsdone=1 ;;
			esac
		fi
		case "$av" in
		*:*) _remote=1 ;;
		esac
	done
	if test -z "$_remote" ; then
		cat << _EOF
  -----
 /     \\
 | o o |
 |     |  -----------------------------------------
 |  |  | /                                         \\
 |     |/  It looks like you're using scp to do a   \\
 | --- |\\  local to local copy. Are you sure? (y|n) /
  \\__  | \\________________________________________/
 \\_____/
_EOF
		read -r _answer
		case "$_answer" in
		Y*|y*) ;;
		*) return 1;
		esac
	fi
	/usr/bin/scp "$@"
}



More information about the openssh-unix-dev mailing list