Mailing List Archive

Getting rid of "Cannot open display" message
Hi all.

I'm using ssh to execute a command on a server. When the remote server
has an X server running, I get a/m message written to standard error.

amit0 ~ # ssh localhost echo bla
Cannot open display "default display"
Cannot open display "default display"
bla

Appending the '-x' parameter, as suggested, doesn't seem to help:

amit0 ~ # ssh -x localhost echo bla
Cannot open display "default display"
Cannot open display "default display"
bla


I want to disable whatever's causing this message. I don't need X
running over the connection.

How do I get rid of this message?

ssh version:
amit0 ~ # ssh -V
OpenSSH_5.2p1, OpenSSL 0.9.8k 25 Mar 2009

10x,
Amit
RE: Getting rid of "Cannot open display" message [ In reply to ]
"-X" capitalize it.

-----Original Message-----
From: listbounce@securityfocus.com [mailto:listbounce@securityfocus.com]
On Behalf Of Amit Dor-Shifer
Sent: Tuesday, May 05, 2009 1:56 AM
To: secureshell@securityfocus.com
Subject: Getting rid of "Cannot open display" message

Hi all.

I'm using ssh to execute a command on a server. When the remote server
has an X server running, I get a/m message written to standard error.

amit0 ~ # ssh localhost echo bla
Cannot open display "default display"
Cannot open display "default display"
bla

Appending the '-x' parameter, as suggested, doesn't seem to help:

amit0 ~ # ssh -x localhost echo bla
Cannot open display "default display"
Cannot open display "default display"
bla


I want to disable whatever's causing this message. I don't need X
running over the connection.

How do I get rid of this message?

ssh version:
amit0 ~ # ssh -V
OpenSSH_5.2p1, OpenSSL 0.9.8k 25 Mar 2009

10x,
Amit
Re: Getting rid of "Cannot open display" message [ In reply to ]
look into your ~/.profile and /etc/profile.
You might be running an X client.

On Mon, May 4, 2009 at 10:56 PM, Amit Dor-Shifer <amitds@oversi.com> wrote:
> Hi all.
>
> I'm using ssh to execute a command on a server. When the remote server
> has an X server running, I get a/m message written to standard error.
>
> amit0 ~ # ssh localhost echo bla
> Cannot open display "default display"
> Cannot open display "default display"
> bla
>
> Appending the '-x' parameter, as suggested, doesn't seem to help:
>
> amit0 ~ # ssh -x localhost echo bla
> Cannot open display "default display"
> Cannot open display "default display"
> bla
>
>
> I want to disable whatever's causing this message. I don't need X
> running over the connection.
>
> How do I get rid of this message?
>
> ssh version:
> amit0 ~ # ssh -V
> OpenSSH_5.2p1, OpenSSL 0.9.8k 25 Mar 2009
>
> 10x,
> Amit
>
>



--
And, did Galoka think the Ulus were too ugly to save?
-Centauri
Re: Getting rid of "Cannot open display" message [ In reply to ]
In the last episode (May 05), Amit Dor-Shifer said:
> Hi all.
>
> I'm using ssh to execute a command on a server. When the remote server
> has an X server running, I get a/m message written to standard error.
>
> amit0 ~ # ssh localhost echo bla
> Cannot open display "default display"
> Cannot open display "default display"
> bla
>
> Appending the '-x' parameter, as suggested, doesn't seem to help:
>
> amit0 ~ # ssh -x localhost echo bla
> Cannot open display "default display"
> Cannot open display "default display"
> bla

You must have something in one of your shell's startup scripts that is
trying to access an X display. Adding a "set -x" at the top of your scripts
will force each line to be printed as it is run, which should help you track
down the offending commands.

--
Dan Nelson
dnelson@allantgroup.com
Re: Getting rid of "Cannot open display" message [SOLVED] [ In reply to ]
Thanks Dan!
The offender was a call to setxkbmap in ~/.bashrc. Two calls, in-fact,
hence the two error messages.

As I now realize, disabling X11 forwarding on either client or server
side wouldn't have helped me a bit, right? If any, it would insure that
I'd get the message, because the message is generated by the X-program,
which gets called anyways, and disabling X-forwarding would just make
the X program more angry.

I caught the program fairly quickly. For those with more complicated
setups, I'd suggest the following diagnostic process for identifying the
cause of the problem:

a) invoke sshd from the cmdline, wrapped by strace, tracing exec() and
write() calls:
strace -f -e trace=process,write -o /tmp/sshd.strace /usr/sbin/sshd
b) Reporduce:
amit0 ~ # ssh localhost echo bla
Cannot open display "default display"
bla
c) Look for the PID that's writing the error message:
29350 write(2, "Cannot open display \"default dis"..., 38) = 38
d) Now locate the exec() call relating to that PID:
29350 execve("/usr/bin/setxkbmap", ["setxkbmap"...,

Amit



Dan Nelson wrote:
> In the last episode (May 05), Amit Dor-Shifer said:
>
>> Hi all.
>>
>> I'm using ssh to execute a command on a server. When the remote server
>> has an X server running, I get a/m message written to standard error.
>>
>> amit0 ~ # ssh localhost echo bla
>> Cannot open display "default display"
>> Cannot open display "default display"
>> bla
>>
>> Appending the '-x' parameter, as suggested, doesn't seem to help:
>>
>> amit0 ~ # ssh -x localhost echo bla
>> Cannot open display "default display"
>> Cannot open display "default display"
>> bla
>>
>
> You must have something in one of your shell's startup scripts that is
> trying to access an X display. Adding a "set -x" at the top of your scripts
> will force each line to be printed as it is run, which should help you track
> down the offending commands.
>
>
Re: Getting rid of "Cannot open display" message [SOLVED] [ In reply to ]
Hi,

Amit Dor-Shifer amitds-at-oversi.com |Lists| wrote:
> I caught the program fairly quickly. For those with more complicated
> setups, I'd suggest the following diagnostic process for identifying the
> cause of the problem:

Or for faster results, try with temporary empty ~/.profile and
~/.bashrc. If that doesn't fail you'll know they are the culprit, then
try deleting lines in your original ~/.profile and ~/.bashrc using
bisection.

And to call the X clients safely once you've identified them:

if [ "$DISPLAY" != "" ] ; then
# Call X clients
setxkbmap yada yada yada
xfoo --bar
fi

Beware, that if you're over a slow SSH connection, it could take time
for the clients to contact your DISPLAY even if it does work.

Especially, to start vi without it taking forever:
vi -X file.ext

Peter
--
Peter Valdemar Mørch
http://www.morch.com