2

I type ssh -X [email protected] and asks for a password, I type it in and get logged in.

[email protected]:~$  program.py

then nothing happens, when it should actually pop up. Why is this happening and how do I solve it?

3
  • @shi what does echo $DISPLAY print when you run it in your ssh session?
    – karthick87
    Dec 18, 2010 at 20:04
  • It displays localhost:14.0
    – shi
    Dec 18, 2010 at 20:26
  • I added the information from your duplicate question which should be closed. Dec 19, 2010 at 20:45

6 Answers 6

3

The problem is that the SSH connection is not forwarding X11 commands over the connection.

If the machine you are using to connect is running Linux (or another OS with X) then simply pass the -X param when invoking SSH.

If you are connecting with Microsoft Windows, you will need a program that can translate X11 commands into Windows API commands. Try looking at XMing or cygwin.

13
  • I typed ssh -X [email protected] got prompted for and typed in password,,, got logged in, then typed "firefox" and nothing happened. Im using ubuntu.
    – shi
    Dec 18, 2010 at 19:44
  • Are there any errors reported? Dec 18, 2010 at 19:45
  • no, just nothing pops up
    – shi
    Dec 18, 2010 at 19:49
  • @shi: Does the command terminate, or do you have to hit Ctrl+C? Dec 18, 2010 at 20:08
  • I don't have to do anything, the terminal appears as normal, just like when I open a program locally, but when I'm in my remote account, the only difference is that the program doesn't pop up.
    – shi
    Dec 18, 2010 at 20:16
3

You may also need to add/uncomment the following line from your /etc/ssh/sshd_config:

X11Forwarding yes

The -X flag is useless without this.

2

You probably need to enable X forwarding in your SSH server's configuration file, /etc/ssh/sshd_config:

X11Forwarding yes

If you don't have access to this file, I'm afraid you will have to ask your sysadmin to enable it.

0

It sounds like your DISPLAY variable is getting set somewhere. When I SSH into my machine from my phone (with X forwarding) and run the following:

oli@bert:~$ echo $DISPLAY
localhost:10.0

Though it's not a guarantee, X forwarding tends to use high display numbers.

If your ~/.bashrc is set to override the display, you'll likely see something more like like :0.

You can either guess and over-override the DISPLAY variable to localhost:10.0 after you connect:

export DISPLAY=localhost:10.0

Of find where you're setting display in your local bash files.


I should add that it's possible to turn off X forwarding in the SSHd settings (/etc/ssh/sshd_config) so you might want to check that too.

2
  • My computer is originally a windows vista,then I used wubi to install ubuntu 10.04.1 . Normally at work when I type in the commands the program opens and pops up in a new window, now on my laptop ubuntu, I type in the exact same thing and nothing pops up.
    – shi
    Dec 18, 2010 at 19:20
  • @shi did you run echo $DISPLAY when connected via SSH? What did you see?
    – Oli
    Dec 19, 2010 at 0:03
0

It is just as you do in your PC,
ssh -X remotehost python remotepythonprogram.py

To view the program code,
ssh -X remotehost less remotepythonprogram.py

6
  • nothing pops up, I try to open other programs from the remote computer that are not python, they don't open either.
    – shi
    Dec 18, 2010 at 17:47
  • 1
    @karthick87 given the -X flag in the connection string, I think we're talking about a graphical X-forwarded application, not a text-mode app.
    – Oli
    Dec 18, 2010 at 18:30
  • yes something like fityk
    – shi
    Dec 18, 2010 at 18:56
  • why doesnt it pop up?
    – shi
    Dec 18, 2010 at 19:03
  • In addition, when I open a program from my local account using terminal, it works. FOr example, I type "firefox"...firefox pops up. Then whe I ssh into my remote account, I type "firefox" nothing happens. What is the problem?
    – shi
    Dec 18, 2010 at 19:29
0

Oliver's solution is the way to go if you want to forward X, but understand that this may be bandwidth-intensive.

An alternate solution is to use a command line editor like vim or nano. Personally, I would go with vim. It does have a steeper learning curve, but once you get past that, you will not want to go back to anything else =) You can start learning it by executing vimtutor for a tutorial on the basics.

You must log in to answer this question.