Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I routinely run sshd on a non-standard port (ie, not 22).

When ssh-ing to my machine I use the -p flag. However, when using scp, the flag is -P (lowercase vs uppercase).

Since they come out of the same suite, why would then not use the same flag capitalization? Is it really just because two different folks wrote it? Neither uses the other form of "p" for anything - wouldn't it make sense for them to work identically*?

*I know - I could modify the source and have a package that accepted both forms: but that does not solve the upstream issue, nor would I expect my patch submission to ever make it into the trunk code (though I'll be giving it a shot).

share|improve this question
up vote 2 down vote accepted

My guess... and this is only a guess... is that -p was already used by rcp for the current meaning of "Preserves modification times, access times, and modes from the original file." And since scp was written to be a drop-in secure replacement for rcp, it was important to honor that flag as rcp understood it. This meant that the option of using a non-standard port had to use another flag.

EDIT: Possible wrapper to convert -P to -p for ssh. It should handle the common cases, but it's not thoroughly tested. To handle even the strangest cases, something that does proper command-line interpretation (such as perl's Getopt modules) would be better.


for x in "$@"; do
    if [ "$END"x == "x" ]; then
        case $x in
            "-P") x="-p" ;;
            "--") END=1 ;;
    ARGS="$ARGS $x"

ssh $ARGS
share|improve this answer
Indeed, rcp uses -p for “preserve metadata”, and it does so to imitate cp. – Gilles Jun 19 '11 at 9:54
that sure sounds plausible – warren Jun 20 '11 at 4:05
though - then the question would still remain, why not use -P for ssh as well? – warren Jun 20 '11 at 4:10
I think ssh existed before scp... so there would have been no reason to use -P instead of -p. But that observation brings up a simple point... it would be trivial to write a ssh wrapper that converted -P to -p, so that you could use -P both places. No need to hack the ssh source and recompile that way. – Flimzy Jun 20 '11 at 4:12
I updated my answer with one such possible wrapper. – Flimzy Jul 6 '11 at 14:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .