Copying Files

PaulStimpson's picture

How many ways are there to copy files from one machine to another...

  • TAR

GNU Tar has a wide range of options. Even without these it's often the simplest way of cloning a section of a filesystem. Use in conjunction with some other mechanism for transporting the tar files from one machine to annother.

  • SCP

Uses the same protocol as ssh. ie. if you have ssh setup then scp should automatically work.

  • SFTP

SFTP is an ftp-like frontend to scp. It doesn't actually use or require FTP.

  • RSYNC

Very useful for automated backups. Uses an incremental algorithm to only transfer the bits of a file that have changed. Can eithr work as a dedicated server (only recommended for anonymous readonly access) or tunnel over ssh.

  • SAMBA (SMB)
  • NFS

Should only be used on trusted networks. Uses host based authentication, so make sure you trust the machines that can connect to an NFS server.

  • SSHFS

Allows you to mount a remote filesystem over ssh. Works just like any other filesystem on the local machine. Dead easy to setup if you already have ssh working. Requires no configuration or additional services on the remote machine. Recent distros should include this. Older distros will need to install the FUSE kernel module. It works reasonably well for a single user. For multiple users each user will need to create their own mount. Some operations don't quite work (eg. file renames are not atomic). In most cases this doesn't matter, but it's probably a bad idea to put mail spools or svn repositories on an sshfs filesystem.

  • FTP

Generally only reccommended for anonymous access, and as a last resort. FTP is not secure, passwords are transmitted in plaintext.

  • HTTP

Good for readonly access, especially if you already have apache running. Setting up a http server can be tricky. It is possible to use things like WebDAV plugins to allow writing to files, but these generally require additional configuration. Very easy to switch to HTTPS for additional transport-level security once you're got it setup.

  • ZSSH (requires the 'zssh' and 'lrzsz' packages on the client plus 'ssh' and 'lrzsz' on the remote machine)

You may want to consider scp instead.

  user@localmachine$ zssh user@remotemachine
  Password:
  user@remotemachine$ sz remotefile.txt
  **▒B00000000000000 <--- Part of ZModem - You can ignore it
  [CTRL]-Space
  zssh > rz
  Receiving: remotefile.txt
  Bytes received:  16055/ 16055  BPS:13914
  Transfer complete
  **0800000000022d <--- Ignore this
  -bash: **0800000000022d: command not found <--- and this!
  user@remotemachine$
  • Email / Webmail
  • Use a remote file storage service like xdrive.com
  • Sneakernet - Carry the file across on physical media

USB flash drives and ipod-like media devices are good for this.

  • RCP

Copy files using rsh/rlogin. Don't use this. Use ssh/scp instead. Some distros (eg. Debian) make rcp a symlink to scp by default.