4

On a machine I don't have physically access to, I left gedit open with a text file I forgot to save. I can ssh to that machine. The OS running there is Ubuntu.

Is there any way I can save that file remotely?

Ricky Robinson
  • 21,798
  • 42
  • 129
  • 185

2 Answers2

4

Look at xdotool, which can programatically activate/move/resize windows, and simulate keyboard input and mouse activity.

xdotool search --classname gedit key ctrl+s

This will search for all of gedit's windows and press ctrl+s in them.

ghoti
  • 45,319
  • 8
  • 65
  • 104
2

Yup! I can think of two straightforward ways.

  1. If you have SSH access and root privileges, you can tunnel in and install and configure a remote desktop viewer (or use the default VNC, vinagre). You can then connect to your desktop, find the gedit window and literally press "save."

  2. You can use X forwarding over SSH to forward the gedit window to your local machine, where you can also just press "save." Note that you'll have to change the X display of the gedit instance so it's forwarded. This may be slightly tricky, but you can give it a try. You'll find many guides to X forwarding with a simple search.

There's definitely a hackish way to take the contents gedit is holding in memory and write them to file, but I think using a VNC client is a much, much simpler option.

David Cain
  • 16,484
  • 14
  • 65
  • 75