Uppsala Multidisciplinary Center for Advanced Computational Science

Yet another way to copy files between Linux machines

xclip is a command line interface to the X11 clipboard. It can also be used for copying files, as an alternative to sftp/scp, thus avoiding password prompts when X11 forwarding has already been setup.

Setup

You need to run X11 (graphical interface) on your local (Linux) machine [1]. This is usually the case if you run recent Linux desktop distribution. Xclip is, however, not available by default, so you need to install it using the distribution provided package manager.

for Debian based distributions:

$> sudo apt-get install xclip

or for Red Hat Enterprise Linux (RHEL):

$> sudo yum install xclip

You need to connect to the remote machine with X11 forwarding, for example:

$>ssh -Y -l USERNAME@milou.uppmax.uu.se

Use

1.) COPY: Open a terminal on your local machine and navigate to your folder containing the files you want to copy. Then select the files or folders you want to copy to the remote machine (UPPMAX).

$> xclip-copyfile directory file1 file2   

2.) PASTE: On the terminal with the remote login session execute the corresponding command to "paste" the files.

$> xclip-pastefile

The entire structure, including the subfolders if you selected a folder, will be copied on the remote machine.

Hints

To make it easier to copy/paste files, add the following two aliases in your .bashrc file

alias xc=xclip-copyfile
alias xp=xclip-pastefile

Notes

[1] A similar setup could be realized under Windows by using a local installation of MobaXterm. To install xclip, type on the command line:

[user@local] MobApt install xclip