Welcome to Blogs @ Andrew Qu
Blog Index
All blogs
Search results

Sharing Clipboard between Windows and Ubuntu (Linux) Using Python


This python program will allow the sharing of clipboard (cut/paste) between 2 work station running Windows and Linux.


At work, I use Windows for most of the daily work, email, Lync, Skype, word processing, Excel etc. I use a Linux box for compiling Android OS images. Often, there is a need to cut/paste contents between these 2 work stations.

Searched the internet, but could not find a very good way to do the job efficiently. So I wrote this Python script clip.py (Click to download).

How to Use the Script

All commands are executed in console windows. Once installed, there are 3 command options:
clip.py /s  -- Send clip board contents to the remote computer
clip.py /r  -- Read the contents just sent by the remote computer 
               and place on the local clipboard
clip.py /d  -- Daemon mode. Once running, the remote and local
               clipboards are automatically synchronized.


Install PythonPython
Install cygwin .  Make sure you can run
> scp
> getclip
Requires xclip
$ sudo apt-get install xclip
ssh client. Make sure you can access
> ssh
ssh client,server

Edit your %userprofile%\.ssh\config file and add the ssh server
  host Unix_ssh_name
  User Unix_account_name

Get IP address:
$ ifconfig
and look for the line inet addr:
(yours will be different)

Make sure you can connect to the Ubuntu machine:

> ssh Unix_ssh_name

copy clip.py into a folder that is in the Windows exe search path, for example, c:\apps\cygwin\bin copy clip.py into a searchable folder, for example,
$ chmod 755 clip.py
C:\temp folder is needed to place temporary filesTemp files are placed in /home/user


Program source code: clip.py


  • When you run for the first time on PC, you need to enter Unix_UserName@Unix_ssh_name
  • The settigns are saved in .ssh/remote_clipsvr.txt. If you want to change server later on, delete file and run clip.py /s
  • On Unix side,  highlight text to select, then run clip.py /s to send. To paste, use middle-button click.
Ads from Google
Dr Li Anchor Profi
Engineering anchorage plate design system
©Andrew Qu, 2014. All rights reserved. Code snippets may be used "AS IS" without any kind of warranty. DIY tips may be followed at your own risk.