LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Problem with SSH from xinitrc (http://www.linuxquestions.org/questions/linux-networking-3/problem-with-ssh-from-xinitrc-879381/)

youarefunny 05-07-2011 03:10 PM

Problem with SSH from xinitrc
 
I am trying to have a sort of 'thin client' computer to display programs that are run on a more powerful computer over SSH. (standard ssh stuff). Anyway, when I run xinit and then ssh -X remote@123.123.1.9 all works beautifully. But I want to have it automaticly (without user input). xinit -e 'ssh -X remote*123.123.1.9' also works nice. The only problems with these two methods are the login xterm. So I went to startx because it doesn't have an xterm (i think). But, when I put the ssh login command in /etc/X11/xinit/xinitrc it doesn't work. It just hangs. Although, I have noticed that, although users doesn't say remote is logged in, ps -e remote says he is running sshd untill I kill the X server (it just displays black).

So, what am I doing wrong or what is a better / the proper way to achieve this?

If it helps:
Server 64bit Arch Linux up-to-date
Client 32bit Ubuntu 10.04 LTS

Thanks for your time.

plpl303a 05-08-2011 01:02 AM

When you do the ssh from the console, does it prompt for a password? If ssh is hanging, perhaps it's waiting for a password.

You can also give the flags

-n -N

and indeed, you probably want to do that, as well as backgrounding the command:


ssh -n -N -X username@machinename &

youarefunny 05-09-2011 07:15 AM

Quote:

Originally Posted by plpl303a (Post 4349750)
When you do the ssh from the console, does it prompt for a password? If ssh is hanging, perhaps it's waiting for a password.

You can also give the flags

-n -N

and indeed, you probably want to do that, as well as backgrounding the command:


ssh -n -N -X username@machinename &

I tried all these things to no avail.

-N causes it to return right away (makes sense)
-n does nothing new (still "hangs")

starting it in the background causes startx to shutdown the X server right away.

Thanks for the help. Do you have any more suggestions or a idea of what might be causing it?

plpl303a 05-09-2011 10:21 PM

Would using vnc be a possibility? That would also fit in with the "thin client" paradigm. It also creates its own private X desktop.

One other question: Are you trying to run just a single X client remotely and display locally or are you trying to display *all* remote X clients locally?

If it's the latter, I don't think startx is designed to do that -- When startx runs, it tries to initialize the display adapter on the system it's running on. So if you ssh to a system and then run startx on that system, the startx program will initialize the display on the remote computer.

If you don't like the xterm, perhaps creating a ~/.xinitrc that runs some program that just sits forever would be helpful (since xinit looks for ~/.xinitrc and if it doesn't find it, it runs xterm. If you create an xinitrc, then xinit will run the programs listed there, and the X server will terminate when the last program in xinitrc exits).

youarefunny 05-10-2011 07:04 AM

Quote:

Originally Posted by plpl303a (Post 4351622)
Would using vnc be a possibility? That would also fit in with the "thin client" paradigm. It also creates its own private X desktop.

I have thought about this but it appears to take more resources. Also the screen doesn't update nicely (it flickers). I may have to use this but I was hoping I could get it working with raw X.

Quote:

Originally Posted by plpl303a (Post 4351622)
One other question: Are you trying to run just a single X client remotely and display locally or are you trying to display *all* remote X clients locally?

I don't quite get the question. I have one computer right now but if I can figure this out I would like to connect more. I want one X server up on each 'branch' connecting to one login with a full desktop session running on the 'central' computer.

Quote:

Originally Posted by plpl303a (Post 4351622)
If it's the latter, I don't think startx is designed to do that -- When startx runs, it tries to initialize the display adapter on the system it's running on. So if you ssh to a system and then run startx on that system, the startx program will initialize the display on the remote computer.

I'm sorry for being unclear, I am running startx on the remote computer to start and X server and then ssh to the 'central' computer that will run all of the clients.

Quote:

Originally Posted by plpl303a (Post 4351622)
If you don't like the xterm, perhaps creating a ~/.xinitrc that runs some program that just sits forever would be helpful (since xinit looks for ~/.xinitrc and if it doesn't find it, it runs xterm. If you create an xinitrc, then xinit will run the programs listed there, and the X server will terminate when the last program in xinitrc exits).

This sounds like a game winner. I will try this out and see how it goes. I thought the xterm was just a 'byproduct' of xinit that is nice for debugging but not for the average desktop user. I'll get back to you as soon as I get a chance to try this out.

youarefunny 05-10-2011 03:41 PM

Thank you. You have helped me to figure this out. It turns out that when ssh is not running interactively bash is not called. You can solve this by calling bash (or any program) via ssh
Code:

ssh -Xn user@host bash
ssh -Xn user@host desktop-session



All times are GMT -5. The time now is 02:48 PM.