• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

How do I run a program in a remote computer ?

I have 2 computers: A and B.

Computer A is used to login into computer B through SSH.

Now, I would like to run a program in computer B, lets say firefox. I am already logged into computer B from computer A, so I can for example type: "mkdir aDir", or "kill 2558", and so on... all those commands work fine.

Conclusion: after a successfull login with SSH, in a console from computer A I can execute commands that take effect in computer B.

THE QUESTION:
How can I start a program in computer B from computer A ???
0
probine
Asked:
probine
  • 5
  • 4
1 Solution
 
ravenplCommented:
same way as mkdir etc.
After You log in from A to B with ssh, any command You issue takes place on computer B.
But if You want use graphical applications, then login with
ssh -X [more options]
-X tells ssh to forward Xserver connection.

> How can I start a program in computer B from computer A ???
You do that. Or You want do it without using ssh, or without using password?
0
 
kfullartonCommented:
What program are you attempting to start?  Are you connecting from a Linux box or Windows box?
0
 
probineAuthor Commented:
I am using 2 Linux machines.

I want to start firefox.

I do not want to display the program in my computer, I want top open firefox in the remote computer.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
ravenplCommented:
> I do not want to display the program in my computer, I want top open firefox in the remote computer.
Oh, You want to run firefox and You want to display it on remote screen.
In short - this is security issue(as You want to display on not owned screen) and it's impossible, but

if You sure the remote Xserver is started
export DISPLAY=:0
#steal authentication info, eg:
cp -av ~user_which_started_x/.Xauthority ~/
firefox
0
 
probineAuthor Commented:
ravenpl, can you explain this code :

#steal authentication info, eg:
cp -av ~user_which_started_x/.Xauthority ~/
firefox
0
 
ravenplCommented:
Xserver will refuse connection to itself unless it's set to accept any connection(rare ocasion) or You steal authentication info.
The info (magic cookie) is usually stored in ~/.Xauthority file of the user which started the X server
0
 
probineAuthor Commented:
Hi ravenpl ,

I don't see the logic on your code. I have tried:
cp -av ~user_which_started_x/.Xauthority ~/

and I get thist:
cp: `/home/testUser/.Xauthority' and `/home/testUser/.Xauthority' are the same file



0
 
ravenplCommented:
OK, let me ask. How do You know remote box has the Xserver started?
You can't (normally) do that from ssh session, as You are not owner of the console...
0
 
probineAuthor Commented:
Well, in this case I am the one that installed both computer with Linux. I am the one that installed KDE in both of them and  I am the one in control of both computer.

So I know that they both have X installed.

Your code is quite extrange... "cp -av ~user_which_started_x/.Xauthority ~/". It seems that this code doesn't copy anything in the remote machine, it only copies the same think in the same computer.
0
 
ravenplCommented:
> So I know that they both have X installed.
But how do You know it was started on the remote?

1. Xserver on the remote machine must be started - otherwise You can't display anything on the remote.
   Someone had to start it. Possibly it's started from init or startup scripts
2. You have to be authorized to Xserver (so it will allow connection from Your applications)
   This usually is done with magic-cookie which is saved on Xserver startup in user home directory in .Xauthority file
   If the Xserver was started by another user, You have to steal the cookie.
   Sometimes You don't have to authorize to X (if X was started without auth requirements)
3. You have to set env variable DISPLAY pointing to the Xserver (export DISPLAY=":0")
4. start the application - but You have no control over the started application, as it's connected to remote Xserver.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now