file copy between computers

6

Click here to load reader

Upload: oylumalatli

Post on 16-Dec-2015

216 views

Category:

Documents


0 download

DESCRIPTION

File Copy

TRANSCRIPT

  • openSUSE DocumentationChapter 11. Copying and Sharing Files / 11.4. Copying Files between Linux Computers

    11.3. Accessing Files on Different OperatingSystems on the same Computer

    11.5. Copying Files between Linux and WindowsComputers with SSH

    11.4. Copying Files between Linux ComputersLinux offers a rich set of protocols you can use to copy files between computers. Which protocol you use depends on how much workyou want to invest and whether you need to be compatible with future Windows installations. The following sections feature variousmethods to transfer files from and to Linux computers. Make sure to have a working network connection, otherwise they will notwork. All scenarios rely on a working name resolution in the network. If your network does not include a name service, use IPaddresses 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 sun.example.comTarget IP 192.168.0.20Source Hostname earth.example.comSource IP 192.168.0.1User tux

    11.4.1. Copying Files with SSHThe following requirements must be met on both server and client:

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

    1.

    If you use a firewall, open the SSH port. Start YaST, and select Security and Users+Firewall. Go to Allowed Services andcheck, 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.

    2.

    11.4. Copying Files between Linux Computers http://www.mpipks-dresden.mpg.de/~mueller/docs/suse10.2/html/...

    1 -> 6 22-01-2015 09:09

  • 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 [email protected]:/foo_file .

    To copy a whole directory structure, use the recursive mode of scp:scp -r [email protected]:/foo_directory .

    If your network does not provide name resolution, use the server's IP address directly:scp [email protected]:/foo_file .

    If you do not know exactly where your files are, use the sftp command. Refer to Section 11.4.1.1: Using the sftp Protocol or see mansftp.11.4.1.1. Using the sftp ProtocolCopying files in KDE or GNOME with SFTP is very simple. Proceed as follows:

    Press Alt - F2 .1. Enter the following at the address prompt:sftp://[email protected]

    2.

    Enter your the password of tux on sun.example.com.3. Drag and drop your server files or directories to your desktop or a local directory.4.

    KDE provides another protocol called fish that can be used if sftp is not available. The usage of this protocol is similar to sftp, justreplace the sftp protocol prefix of the URL by fish.11.4.2. Transferring Files with rsyncBefore using rsync to synchronize file and directories between different computers, make sure the following requirements are met:

    11.4. Copying Files between Linux Computers http://www.mpipks-dresden.mpg.de/~mueller/docs/suse10.2/html/...

    2 -> 6 22-01-2015 09:09

  • The package rsync is installed.1. Identical users are available on both systems.2. Enough disk space is available on the server.3. If you want to benefit from rsync's full potential, make sure rsyncd is installed on one of the systems.4.

    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 usedas a daemon to provide directories to the network (see Advanced Setup for rsync Synchronization).

    11.4.2.1. rsync Basic ModeThe basic mode of operation of rsync does not require any special configuration. rsync allows mirroring of complete directories ontoanother system out of the box. Its usage is not much different from a regular copying tool, such as scp. The following commandcreates 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/

    11.4.2.2. rsync Daemon ModeStart the rsyncd daemon on one of your systems to make use of the full functionality of rsync. In this mode it is possible to createsynchronization points (modules) that can be accessed without account. To use the rsyncd daemon, proceed as follows:Procedure 11.1. Advanced Setup for rsync Synchronization

    Log in as root and install the rsync package.1. Configure your synchronization points:gid = nobodyuid = nobody

    2.

    11.4. Copying Files between Linux Computers http://www.mpipks-dresden.mpg.de/~mueller/docs/suse10.2/html/...

    3 -> 6 22-01-2015 09:09

  • read only = trueuse chroot = notransfer logging = truelog format = %h %o %f %l %blog file = /var/log/rsyncd.log[FTP] path = /srv/ftp comment = An Example

    Start the rsyncd daemon as user root:rcrsyncd start

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

    3.

    List all files located in the /srv/ftp directory (note the double colon):rsync -avz sun::FTP

    4.

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

    5.

    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 resolvedmanually.11.4.3. Copying Files with FTP

    Use Setup for Home Networks OnlyThe setup featured in the following sections is suited for use in home networks only. Do notdeploy it to sites wholly unprotected by firewalls and do not enable world wide access.

    To configure an FTP server, proceed as follows:

    11.4. Copying Files between Linux Computers http://www.mpipks-dresden.mpg.de/~mueller/docs/suse10.2/html/...

    4 -> 6 22-01-2015 09:09

  • Prepare the FTP server:Install the vsftp package.a. Open a shell, login as root and save a backup copy of /etc/vsftpd.conf:cp /etc/vsftpd.conf /etc/vsftpd.conf.bak

    b.

    Create an access point for anonymous FTPmkdir ~ftp/incomingchown -R ftp:ftp ~ftp/incoming

    c.

    1.

    Replace the configuration files depending on the scenario you prefer (refer to the manual page of vsftpd.conf for advancedconfiguration options):Allowing Anonymous Read and Write Access

    #listen=YES# Enable anonymous access to FTP serveranonymous_enable=YES#local_enable=YES# Enable write accesswrite_enable=YESanon_upload_enable=YESanon_mkdir_write_enable=YESdirmessage_enable=YES# Write log file xferlog_enable=YESconnect_from_port_20=YESchown_uploads=YESchown_username=ftpftpd_banner=Welcome to FTP service.anon_root=/srv/ftp

    Grant Restricted Permissions to FTP Users (Home Only)

    2.

    11.4. Copying Files between Linux Computers http://www.mpipks-dresden.mpg.de/~mueller/docs/suse10.2/html/...

    5 -> 6 22-01-2015 09:09

  • chroot_local_users=YES

    Restart the FTP server:rcvsftp start

    3.

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

    11.3. Accessing Files on Different OperatingSystems on the same Computer

    11.5. Copying Files between Linux and WindowsComputers with SSH

    11.4. Copying Files between Linux Computers http://www.mpipks-dresden.mpg.de/~mueller/docs/suse10.2/html/...

    6 -> 6 22-01-2015 09:09