LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 06-20-2003, 10:12 AM   #1
msound
Member
 
Registered: Jun 2003
Location: SoCal
Distribution: CentOS
Posts: 465

Rep: Reputation: 30
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?
 
Old 06-20-2003, 12:04 PM   #2
DavidPhillips
Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,154

Rep: Reputation: 56
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
 
Old 06-20-2003, 12:29 PM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
I agree with David - VNC is much more protable through distributions but Xforwarding is much faster on slower networks.
 
Old 06-20-2003, 12:46 PM   #4
cyph3r7
Member
 
Registered: Apr 2003
Location: Silicon Valley East, Northern Virginia
Distribution: FreeBSD,Debian, RH, ok well most of em...
Posts: 238

Rep: Reputation: 30
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
 
Old 06-20-2003, 12:49 PM   #5
msound
Member
 
Registered: Jun 2003
Location: SoCal
Distribution: CentOS
Posts: 465

Original Poster
Rep: Reputation: 30
Quote:
export DISPLAY=ipofmachineyouwantdisplayon:0.0
ok, so i ssh into that machine and then type that command?
 
Old 06-20-2003, 01:44 PM   #6
DavidPhillips
Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,154

Rep: Reputation: 56
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.

Last edited by DavidPhillips; 06-20-2003 at 01:46 PM.
 
Old 06-20-2003, 02:08 PM   #7
DavidPhillips
Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,154

Rep: Reputation: 56
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.
 
Old 06-20-2003, 02:38 PM   #8
DavidPhillips
Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,154

Rep: Reputation: 56
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

Last edited by DavidPhillips; 06-20-2003 at 02:54 PM.
 
Old 06-20-2003, 03:35 PM   #9
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 46
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.

Last edited by moses; 06-20-2003 at 03:37 PM.
 
Old 06-20-2003, 03:51 PM   #10
DavidPhillips
Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,154

Rep: Reputation: 56
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

Last edited by DavidPhillips; 06-20-2003 at 04:07 PM.
 
Old 06-24-2003, 03:47 PM   #11
acjt
Member
 
Registered: Dec 2002
Location: Australia
Distribution: Gentoo
Posts: 161

Rep: Reputation: 30
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!
 
Old 06-24-2003, 07:21 PM   #12
DavidPhillips
Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,154

Rep: Reputation: 56
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

Last edited by DavidPhillips; 06-24-2003 at 09:19 PM.
 
Old 06-24-2003, 09:27 PM   #13
DavidPhillips
Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,154

Rep: Reputation: 56
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

Last edited by DavidPhillips; 06-24-2003 at 09:33 PM.
 
Old 06-24-2003, 10:04 PM   #14
DavidPhillips
Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,154

Rep: Reputation: 56
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.
 
Old 06-24-2003, 11:37 PM   #15
KevinJ
Member
 
Registered: Feb 2001
Location: Colorado Springs, CO
Distribution: Redhat v8.0 (soon to be Fedora? or maybe I will just go back to Slackware)
Posts: 857

Rep: Reputation: 30
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh is not starting!!! jsheffie Solaris / OpenSolaris 6 08-19-2005 02:02 PM
Starting ssh on fedora tobycatlin Linux - Software 5 05-13-2005 07:52 AM
starting kde over SSH Danathar Slackware 6 12-02-2004 10:29 AM
Starting SSH problem satimis Linux - Software 4 10-28-2003 09:04 PM
Starting SSH Server cli_man Linux - Software 3 04-10-2002 10:09 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration