11.4. Copying Files between Linux Computers

Linux offers a rich set of protocols you can use to copy files between computers. Which protocol you use depends on how much work you want to invest and whether you need to be compatible with future Windows installations. The following sections feature various methods to transfer files from and to Linux computers. Make sure to have a working network connection, otherwise they will not work. All scenarios rely on a working name resolution in the network. If your network does not include a name service, use IP addresses directly or add the IP addresses along with respective hostnames in /etc/hosts on all clients.

The following example IP addresses and hostnames are used across this section:

Target Hostname


Target IP

Source Hostname


Source IP



11.4.1. Copying Files with SSH

The following requirements must be met on both server and client:

  1. Make sure hostnames of IP addresses of both server and client are known across the network. Each hostname needs to be listed in /etc/hosts, for both server and client (see Section “ /etc/hosts ” (Chapter 21, Basic Networking, ↑Reference).)

  2. If you use a firewall, open the SSH port. Start YaST, and select Security and Users+Firewall. Go to Allowed Services and check, whether SSH is displayed as part of the list. If this is not the case, select SSH from Service to Allow and click Add. Apply your changes and leave YaST with Next and Accept.

To copy files from a server to a client, you need to know where the files are located on the server. For example, to copy a single file /srv/foo_file from the server to the current directory, use the scp command (do not forget the dot!):

scp tux@sun.example.com:/foo_file .

To copy a whole directory structure, use the recursive mode of scp:

scp -r tux@sun.example.com:/foo_directory .

If your network does not provide name resolution, use the server's IP address directly:

scp tux@ .

If you do not know exactly where your files are, use the sftp command. Refer to Section Using the sftp Protocol or see man sftp. Using the sftp Protocol

Copying files in KDE or GNOME with SFTP is very simple. Proceed as follows:

  1. Press Alt-F2.

  2. Enter the following at the address prompt:

  3. Enter your the password of tux on sun.example.com.

  4. Drag and drop your server files or directories to your desktop or a local directory.

KDE provides another protocol called fish that can be used if sftp is not available. The usage of this protocol is similar to sftp, just replace the sftp protocol prefix of the URL by fish.

11.4.2. Transferring Files with rsync

Before using rsync to synchronize file and directories between different computers, make sure the following requirements are met:

  1. The package rsync is installed.

  2. Identical users are available on both systems.

  3. Enough disk space is available on the server.

  4. If you want to benefit from rsync's full potential, make sure rsyncd is installed on one of the systems.

rsync is useful for archiving or copying data. You only need a remote shell (such as ssh) on the target system. rsync can also be used as a daemon to provide directories to the network (see Advanced Setup for rsync Synchronization). rsync Basic Mode

The basic mode of operation of rsync does not require any special configuration. rsync allows mirroring of complete directories onto another system out of the box. Its usage is not much different from a regular copying tool, such as scp. The following command creates a backup of the home directory of tux on a backup server called sun:

rsync -Hbaz -e ssh /home/tux/ tux@sun:backup

Use the following command to apply your backup:

rsync -Haz -e ssh tux@sun:backup /home/tux/ rsync Daemon Mode

Start the rsyncd daemon on one of your systems to make use of the full functionality of rsync. In this mode it is possible to create synchronization points (modules) that can be accessed without account. To use the rsyncd daemon, proceed as follows:

Procedure 11.1. Advanced Setup for rsync Synchronization

  1. Log in as root and install the rsync package.

  2. Configure your “synchronization points”:

    gid = nobody
    uid = nobody
    read only = true
    use chroot = no
    transfer logging = true
    log format = %h %o %f %l %b
    log file = /var/log/rsyncd.log
      path = /srv/ftp
      comment = An Example
  3. Start the rsyncd daemon as user root:

    rcrsyncd start

    To automatically start the rsync service upon system boot, call:

    insserv rsyncd
  4. List all files located in the /srv/ftp directory (note the double colon):

    rsync -avz sun::FTP
  5. Initiate the transfer by providing a target directory (in this example the current directory is represented by a dot):

    rsync -avz sun::FTP .

By default, files are not deleted while synchronizing with rsync. To force file deletion, add the --delete option. To make sure that the --delete does not accidentally remove newer files, use the --update option instead. Any conflicts that arise must be resolved manually.

11.4.3. Copying Files with FTP

[Warning]Use Setup for Home Networks Only

The setup featured in the following sections is suited for use in home networks only. Do not deploy it to sites wholly unprotected by firewalls and do not enable world wide access.

To configure an FTP server, proceed as follows:

  1. Prepare the FTP server:

    1. Install the vsftp package.

    2. Open a shell, login as root and save a backup copy of /etc/vsftpd.conf:

      cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
    3. Create an access point for anonymous FTP

      mkdir ~ftp/incoming
      chown -R ftp:ftp ~ftp/incoming
  2. Replace the configuration files depending on the scenario you prefer (refer to the manual page of vsftpd.conf for advanced configuration options):

    Allowing Anonymous Read and Write Access
    # Enable anonymous access to FTP server
    # Enable write access
    # Write log file 
    ftpd_banner=Welcome to FTP service.
    Grant Restricted Permissions to FTP Users (Home Only)
  3. Restart the FTP server:

    rcvsftp start

On the client, just enter the URL ftp://HOST in your browser or FTP client. Replace HOST with either the hostname or the IP address of your server. There are many graphical user interfaces available that are suited to browse the contents of your FTP server. For a list of them, just enter FTP at the search prompt of the YaST package manager.