I'm accessing my Pi via SSH.

My network is too slow to actually forward the Pi's desktop back to my laptop, so I have a monitor connected to my Pi. When I startx through Putty, I see the desktop on my Pi. All is good.

However, I cannot do anything with this desktop, as all I have is the mouse and keyboard of my laptop.

How can I forward the mouse and keyboard input from my laptop to the desktop on my Pi?

  • If you're connecting a monitor anyway, why not connect a keyboard and mouse? You normally use ssh when you when you dont have access to the PI itself. Dec 31, 2012 at 18:59
  • 1
    @Ash I don't have a keyboard. I know they're cheap and everything, but it would make it easier...
    – ACarter
    Dec 31, 2012 at 19:16
  • If you only have a single keyboard and mouse, it might make sense to get a KVM switch so you can go back and forth.
    – Kibbee
    Jan 1, 2013 at 0:18
  • I'm sure I've written about this before somewhere.
    – Jivings
    Jan 1, 2013 at 13:35
  • 1
    @Kibbee I thought you couldn't use a KVM switch with a laptop?
    – ACarter
    Jan 1, 2013 at 14:30

5 Answers 5


You can use a great tool called x2x. This essentially treats the monitor connected to the remote device (the Raspberry Pi) as a second X screen to you existing session as if you had two monitors connected.

Install x2x on both devices:

sudo pacman -S x2x         # Arch Linux
sudo apt-get install x2x   # Debian/Raspbian 

Configure SSH:

On the Raspberry Pi edit /etc/ssh/sshd_config and add/uncomment the following line:

X11Forwarding yes

Then restart the ssh server.

SSH to the Pi from your other device and run x2x:

ssh -X 'x2x -east -to :0'

Replace the IP with the address of your Raspberry Pi.

Now you should be able to move your mouse between the two X sessions by moving your mouse off the screen to the right (east).

  • When doing this on both Windows and Ubuntu, I'm getting an error similar to x2x - error: can not open display :0. I've installed x2x on the Pi and Ubuntu, and SSH is set up on the Pi.
    – ACarter
    Jan 1, 2013 at 15:00
  • @ACarter I don't think you can involve Windows (unless your using xming) as it needs an X session running at each end.
    – Jivings
    Jan 1, 2013 at 15:38
  • Do I need to explicitly start the X session on Ubuntu then?
    – ACarter
    Jan 1, 2013 at 16:30
  • @ACarter Yes, it treats the connection as an extension of your existing X session.
    – Jivings
    Jan 1, 2013 at 20:26
  • 1
    @ACarter I'm sorry about that. It could be something to do with the DISPLAY variable. Try typing echo $DISPLAY in a terminal and replace the :0 in the x2x command with that output.
    – Jivings
    Jan 1, 2013 at 23:29

synergy can do this quite well

Synergy lets you easily share your mouse and keyboard between multiple computers on your desk, and it's Free and Open Source. Just move your mouse off the edge of one computer's screen on to another. You can even share all of your clipboards. All you need is a network connection. Synergy is cross-platform (works on Windows, Mac OS X and Linux).

  • How did you build it for the Pi? Jan 1, 2013 at 15:56
  • @HeatfanJohn, raspbian has it in the repo Jan 1, 2013 at 20:19
  • Ah, sudo apt-get install synergy ... cool! Jan 1, 2013 at 22:52

A quick google eventually led me here and after a quick test this worked for me.

In short you need to setup xrdp

sudo apt-get install xrdp

Once install it will set the rdp service to start on boot, so restart your RPi. When your RPi has finished booting you will be able to connect to your RPi through Windows built-in (or any other third party) remote desktop application.

  • Thanks for your answer, that's a neat remote solution, but the idea is that I see the desktop on the screen connected to the Pi, but I can input to this desktop from my laptop's keyboard.
    – ACarter
    Jan 1, 2013 at 14:33

Old thread... I know.

I've written a utility I call fauxcon, which forwards your keyboard (and soon, mouse) to the console of another computer you're ssh'd into.

This allows you to view your RPi's display (for instance) on a TV or monitor, and type as if you were logged into the physical device with a keyboard.

Considering everything in my house is wireless, it's rather neat to sit on the couch with laptop and type away, seeing it happen on the big screen on the RPi.

Feedback welcome,

fauxcon - Github - https://github.com/lornix/fauxcon


I was in a similar situation and didn't want to use synergy because I was already running synergy on the computers I wanted to send the keyboard to and don't have X running on the host. I found uinput-mapper to be the perfect solution for my case.

Github: https://github.com/MerlijnWajer/uinput-mapper

How-to: http://blog.pi3g.com/2014/03/uinput-mapper-redirecting-keyboard-and-mouse-to-any-linux-system-using-a-raspberry-pi/

I used netcat instead of SSH since I'm not too worried about security on my LAN and it seems to intercept the keyboard before you can type your password. Must be run as root or more ideally just have privilege to mess with input devices.

On the computer in need of a keyboard:

# nc -l -p 7005|./input-create 

Then on the computer with the keyboard:

# ./input-read -G /dev/input/eventX -D|nc 7005 

(where eventX is your keyboard and 192.X.X.X is the computer you're sending the keyboard to)

It's had no speed issues and all the keys work correctly. I believe it works with mice too but I didn't have a need to use that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.