scp command working in bash doesn't work in zsh

The problem is that zsh is globbing the remote path. You can verify this by

scp luna4:"/u/paige/maye/src/diviner/notebooks/plots/hk_*" .

To turn globbing off for scp remote paths, but otherwise leave globbing the same (from here) add this to your .zshrc -

# Disable globbing on the remote path.
alias scp='noglob scp_wrap'
function scp_wrap {
  local -a args
  local i
  for i in "$@"; do case $i in
    (*:*) args+=($i) ;;
    (*) args+=(${~i}) ;;
  esac; done
  command scp "${(@)args}"
}

If you use single quotes, then it works:

scp 'remote.host.com:files*' .

Tags:

Scp

Zsh