copy files to and from a server

Copy a file or a whole folder between this machine and another one over ssh.

  • network
  • files

Steps

  1. scp file.txt NAME@host:/path/

    send a file to the server

  2. scp NAME@host:/path/file.txt .

    fetch a file from the server into this folder

  3. scp -r NAME@host:/path/folder .

    fetch a whole folder

  4. scp -P 2222 file.txt NAME@host:/path/

    when the server's ssh listens on another port

  5. rsync -avz --progress folder/ NAME@host:/path/folder/

    send a folder, only what changed, with progress; it can be run again to resume

  6. sftp NAME@host

    browse the server and copy with get and put

Notes

  • scp and rsync use the same login as ssh: keys, passwords and ~/.ssh/config hosts all work.

Commands used

  • scp
  • rsync
  • sftp
  • ssh

Each has a page in lore: lore scp opens it.