Copying contents of a folder via SCP results in `scp: error: unexpected filename: .`

6,158

I think your interpretation is correct. It was probably an undocumented feature, removed from the undocumented api (see the web archive of the protocol). One workaround is for you to create a symbolic link in the backup directory before the copy.

ln -s . folder2 
Share:
6,158

Related videos on Youtube

finefoot
Author by

finefoot

Updated on September 18, 2022

Comments

  • finefoot
    finefoot over 1 year

    I was using a script to copy the contents of a folder via SCP, without copying the folder itself. Something like this:

    scp -i id_rsa -P "$PORT" -r "$HOST:/folder1/folder2/." "backup"
    

    (I'm not able to use * because I want to include dot files, too.)

    This has recently stopped working and I'm getting the following error:

    scp: error: unexpected filename: .
    

    I think the cause for this are these changes to SCP from November 2018.

    Does this mean I'm no longer able to copy contents of a folder via SCP without copying the folder itself?

    • Nasir Riley
      Nasir Riley about 5 years
      Why not just use rsync instead? It does exactly what you're trying to do.