Connecting Tech Pros Worldwide Help | Site Map

how to start a program in the gui of remote machine over ssh

Newbie
 
Join Date: Apr 2009
Location: Pretoria, South Africa
Posts: 6
#1: Apr 19 '09
Hi there,

I work in an IT support department and I'm a trainee - i started end of October 2008.
Last week the office was quiet and I found an interesting ssh feature: remotely running a program on remote gui desktop. problem is i couldnt do it even if i had my key on the remote pc. i only managed to put xeyes on my desktop and turn my managers pc into a coo coo clock (every 15mins the cd tray would open and close).

How would it be done?
we both use ubuntu 8.04 and know each others pass and have our authorised keys.

many thanks
Malcs
Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,466
#2: Apr 19 '09

re: how to start a program in the gui of remote machine over ssh


So what you're saying is that it worked fine with two computers, but a different one wouldn't start whatever you asked it to start?
And just to clarify: What you are doing is that from Computer A you log in to Computer B and start a program that will run on a GUI (or more accurately: on an X-Server) in Computer B, right?
If I am right, are there any differences between the computers it works with and that one that it doesn't work on that you could tell us about? Anything, that might stop you from doing what you are trying to do?

Greetings,
Nepomuk


Note to others who don't know: As ssh requires a user account on any PC you do this to, so it is not considered illegal and may therefore be discussed here.
Newbie
 
Join Date: Apr 2009
Location: Pretoria, South Africa
Posts: 6
#3: Apr 19 '09

re: how to start a program in the gui of remote machine over ssh


erm.. A = my computer; B = manager/other/remote pc.

ssh from A to B and run "xeyes": result = xeyes running on A;
ssh from A to B and run "eject -T /dev/dvdrom1; eject -T /dev/dvdrom1": result = dvdrom1 opens/closes on B.

it works with a command line program, but fails with a gui program. we both ssh each other without giving the password, almost everyday to send wall msgs to each other if jabber doesnt get the msg thru..

hope i answered your questions.
Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,466
#4: Apr 19 '09

re: how to start a program in the gui of remote machine over ssh


For the first scenario, you'll have to use ssh -X [user@]host, which enables X forwarding (if you don't understand the latter, don't worry). Does that answer your question?

Greetings,
Nepomuk
Newbie
 
Join Date: Apr 2009
Location: Pretoria, South Africa
Posts: 6
#5: Apr 19 '09

re: how to start a program in the gui of remote machine over ssh


ye.
what if i add -f. does that change the behaviour?
and then if i CTRL-z and restart the job with bg %.... will the remote program be paused and un-paused or stopped and started?

SMiLE
Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,466
#6: Apr 19 '09

re: how to start a program in the gui of remote machine over ssh


Quote:

Originally Posted by malcsman View Post

what if i add -f. does that change the behaviour?

It works as you would expect: ssh goes to the background and runs the command with a GUI.
Quote:

Originally Posted by malcsman View Post

and then if i CTRL-z and restart the job with bg %.... will the remote program be paused and un-paused or stopped and started?

Quite honestly, I don't know for sure. But how about you testing it and then posting your results here?

Greetings,
Nepomuk
Reply