I am trying to copy a folder to remote Ubuntu server using command line ssh connection, i understand it's doable to transfer a file using scp but i have many files in a folder iam trying to copy to that remote server, how is that done? anyone? Thank you.


1 Answer 1


You can use secure copy (scp) with the recursive option (-r):

scp -r /path/to/local/dir user@remotehost:/path/to/remote/dir

Alternatively, I recommend rsync because you can resume transfers if the connection breaks, and it intelligently transfers only the differences between files:

rsync -avz -e 'ssh' /path/to/local/dir user@remotehost:/path/to/remote/dir

Note that in both cases you should be careful of trailing slashes: moving /path/to/local/dir to remotehost:/path/to/remote/dir/ results in /path/to/remote/dir/dir

  • Won't it ask for remote machine's password? I tried the above command and got Host key verification failed.
    – CKM
    Mar 30, 2017 at 5:16
  • Depends on the ssh server setup, but generally yes, it will use a key to authenticate and fallback to password if it's allowed.
    – amc
    Mar 30, 2017 at 13:54
  • This is seriously slow. Any better /much faster alternatives? Apr 13, 2020 at 22:31
  • Much much faster approach is here unix.stackexchange.com/a/10037/66602 Apr 13, 2020 at 22:45
  • 1
    I have my ssh private key, how can I use it with scp?
    – Franva
    May 27, 2021 at 5:39

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