LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   starting X through ssh (https://www.linuxquestions.org/questions/linux-general-1/starting-x-through-ssh-66836/)

msound 06-20-2003 10:12 AM

starting X through ssh
 
ok i have 2 computers running red hat 7.3. Each has X installed. when i ssh into one computer from another, is there any way to use a GUI while working through ssh? kind of like pcanywhere or windows remote desktop? if so can you please explain how to do this. I know whenever I enter any X commands in ssh it tells me that X is already running on display 0. can anyone help me out?

DavidPhillips 06-20-2003 12:04 PM

I usually run the X display of the ssh server in a window on the client.

You can do this with vnc.

http://www.tightvnc.com/
http://www.uk.research.att.com/vnc

There are very many possibilities with vnc.

I normally use it by forwarding the vncserver listening port on the server to the client via ssh, then connect to the clients local port with vncviewer. This encrypts the connection.

http://www.uk.research.att.com/vnc/sshvnc.html

david_ross 06-20-2003 12:29 PM

I agree with David - VNC is much more protable through distributions but Xforwarding is much faster on slower networks.

cyph3r7 06-20-2003 12:46 PM

simple:

on your remote machine simply type:

export DISPLAY=ipofmachineyouwantdisplayon:0.0

ipofmachineyouwantdisplayon obviously means just that, then just type your command and viola...magic

msound 06-20-2003 12:49 PM

Quote:

export DISPLAY=ipofmachineyouwantdisplayon:0.0
ok, so i ssh into that machine and then type that command?

DavidPhillips 06-20-2003 01:44 PM

that's right,

now here is another suggestion that you might try

1. start a normal X session on the local machine

2. open an xterm

3. run this command in the xterm
xhost +remotemachine

4. run this command in the xterm
ssh -X remotemachine

That's it, just run any X app you want on the remote machine by typing the command in the xterm


Also if you start X on the local machine without a window manager you could also run a window manager from the remote machine, because it's an X app, that's a lot slower though. You really just want to run the X apps for the best performance.

DavidPhillips 06-20-2003 02:08 PM

While this is not a remote desktop, unless you start a window manager from the xterm. It is by far the best way to be able to run X apps on a remote machine and still maintain security.

If you want a remote desktop I would go with vnc over ssh or setup your local machine to where you can run xinit without starting a window manager and then crank up wmaker or other wm from the ssh login.

DavidPhillips 06-20-2003 02:38 PM

Ok

One more time


I decided to try the window manager and see if there would be a problem. Here is what you will probably run into.


If you have a file /etc/skel/.xinitrc or /home/username/.xinitrc that starts a window manager on the local machine you need to move or edit it

then run the command...

xinit

you will get an xterm with no window manager

then run ..
xhost +remotemachine

then..
ssh -X remotemachine

then..
wmaker


or other window manager to start the remote desktop

moses 06-20-2003 03:35 PM

On the host machine, edit the /etc/ssh/sshd_config file. Make sure you have the following lines enabled (set to yes):

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

restart sshd.

On the client machine (the one you are sshing from), edit the /etc/ssh/ssh_config file and make sure the following lines are enabled:
ForwardAgent yes
ForwardX11 yes

Make sure you don't have a local (~/.ssh_config) file that overrides these directives.

From an X session on your client machine, ssh in to your host machine and run an X program (xv, for example). xv should pop up on your local machine. It's running on your host machine. . . Do the same for other programs.

DavidPhillips 06-20-2003 03:51 PM

If you still want to run the hosts window manager then you can also bypass the .xinitrc like this from a terminal


xinit -e ssh -X remotemachine wmaker

X will start and you will be logged into remotemachine, then wmaker will start


If you already have a X server running on the local machine use something like this

xinit -e ssh -X remotemachine wmaker -- :1

acjt 06-24-2003 03:47 PM

I tried this:
xinit -e ssh -X remotemachine gnome-session -- :1
however it just opened up a new xsession on the local machine, rather than the remote machine!

DavidPhillips 06-24-2003 07:21 PM

does it prompt for your ssh password (if you use one) or give errors?


maybe try it one step at a time


xinit -e ssh -X remotemachine -- :1

then run gnome-session

DavidPhillips 06-24-2003 09:27 PM

someone else want to test this?

xinit -e ssh -X remotemachine wmaker -- :1

remotemachine being the FQDN (domain name) or ip address of the machine you are connecting to, and wmaker being any valid window manager on your system

I have only tried the following

Slackware 9.0.0 connecting to RedHat 7.3

DavidPhillips 06-24-2003 10:04 PM

One thing that might cause a problem is trying to run the command from within X. ctrl_alt_F1, F2, F3, etc. out to a terminal and try it there if your getting errors in an xterm.

KevinJ 06-24-2003 11:37 PM

Okay... I am getting a bit confused here.. but Msound, are you trying to run an entire nested Xwindows session on your remote desktop.. or are you simply trying to have Xwindows applications that are running on the remote server displayed on your local machine?

I agree with the posters above, in that if you are trying to run an entire desktop, then VNC is definitely the way to go. "man vncserver" and "man vncviewer" for all the info you need.

If however, you just want to have say something like Mozilla running on the remote server, but displaying on your local machine... then it should work by default with RH v7.3. Just ssh into the remote server and issue the command line command for whatever app you want to run (i.e. "mozilla", etc) and it will by default display on your local machine.

-KevinJ

DavidPhillips 06-25-2003 12:30 AM

I did this at home a few days ago, I am on a modem now. I did connect to one machine from here using dialup and this command from my local terminal

xinit -e ssh -X mydomain.com -- :1


On a modem it's too slow, however on a fast network it works quite well. At home I did this with three machines

in a terminal I run this...
xinit -e ssh -X www.mydomain.com -- :1 &
xinit -e ssh -X firedragon.mydomain.com -- :2 &
xinit -e ssh -X slacker.mydomain.com -- :3 &

so then I can access the local machine at ctrl_alt_F7, www at ctrl_alt_F8, firedragon at ctrl_alt_F9, and slacker at ctr_alt_F10


All times are GMT -5. The time now is 07:36 AM.