scp: What would cause it to do a local cp instead of my intended scp? - SSH

This is a discussion on scp: What would cause it to do a local cp instead of my intended scp? - SSH ; I think I just found the answer, but wanted to run it by someone who knows better. Is the : required in a source/destination that is remote? It seems odd to me but maybe that is the only way scp ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: scp: What would cause it to do a local cp instead of my intended scp?

  1. scp: What would cause it to do a local cp instead of my intended scp?

    I think I just found the answer, but wanted to run it by someone who
    knows better. Is the : required in a source/destination that is
    remote? It seems odd to me but maybe that is the only way scp can
    determine the difference between a local and remote copy. I thought
    scp was broken because it was making a local file named the same as my
    destination instead of copying the file to the intended destination.
    Hopefully my example below is clear. Thanks!

    [fbowen@Desktop01 ~]$ ls
    x
    [fbowen@Desktop01 ~]$ scp x fbowen@unknown1 # no colon, local cp
    [fbowen@Desktop01 ~]$ ls
    fbowen@unknown1 x
    [fbowen@Desktop01 ~]$ scp x fbowen@unknown1: # colon
    x 100% 0 0.0KB/s
    00:00
    [fbowen@Desktop01 ~]$ ssh unknown1 "uname -n;ls -l"
    Unknown1
    -rw-rw-r-- 1 fbowen fbowen 0 Feb 18 19:58 x
    [fbowen@Desktop01 ~]$


  2. Re: scp: What would cause it to do a local cp instead of my intended scp?

    >>>>> "FB" == franklin bowen@gmail com writes:

    FB> I think I just found the answer, but wanted to run it by someone
    FB> who knows better. Is the : required in a source/destination that
    FB> is remote? It seems odd to me but maybe that is the only way scp
    FB> can determine the difference between a local and remote copy.

    Yes, though I'm not sure why it would seem odd; otherwise, the token
    "foo@bar" is clearly ambiguous. Anyway, it's documented:

    $ man scp
    NAME
    scp -- secure copy (remote file copy program)

    SYNOPSIS
    scp [-1246BCEpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
    [-l limit] [-o ssh_option] [-P port] [-S program]
    > [[user@]host1:]file1 [...] [[user@]host2:]file2


    DESCRIPTION
    scp copies files between hosts on a network. It uses ssh(1) for data
    transfer, and uses the same authentication and provides the same security
    as ssh(1). Unlike rcp(1), scp will ask for passwords or passphrases if
    they are needed for authentication.

    > Any file name may contain a host and user specification to indicate that
    > the file is to be copied to/from that host. Copies between two remote
    > hosts are permitted.


    The synopsis shows that the colon occurs if and only if there is a host
    (and possbibly user ) specification, which indicates a remote copy.

    - Richard


+ Reply to Thread