Every time i ssh into my raspberry pi, i get message:

Cannot open display "default display"

I've tried going into raspi-config and installing all the locales. Doesn't change anything. I've then tried googling it and nothing seems to work.

What do I do to make it go away?

  • Are you logging in using a console and trying to run GUI apps? Jan 5 '20 at 20:43
  • im logging in via terminal. no im not trying to run gui apps, not even -x with the ssh.
    – john-jones
    Jan 5 '20 at 21:01
  • What app are you using to make the SSH connection? Jan 5 '20 at 21:03
  • no app. just terminal.
    – john-jones
    Jan 5 '20 at 21:06
  • A terminal is an app. What terminal? Putty or WSL terminal can be used in Windows. What machine are you using? Windows or Linux or something else? Do you get the message after you log in? Does it stop you entering user name and password? Can you type any commands like uname or ls -l -a ? Much more information please. Jan 5 '20 at 21:13

Possibly there is something in the remote user's .bashrc file that tries to start something that wants to use the X display? That is what the message usually means. If you can't find anything, what happens if you edit the logged in user's .bashrc and make the last line to be the clear command and then log in again? Also, try looking in /var/log/syslog for clues.

  • Love the 'clear' solution. Problem still exists but you don't see it.
    – gnuchu
    Mar 1 '21 at 13:18

in the bashrc file i was sourcing multiple other files. and it turned out to be an xkeymap call that caused the message. Turns out the x in xkeymap is for... -x

You can test whether a console login is via SSH or not like this

if [[ $(who -m) =~ \([-a-zA-Z0-9\.]+\)$ ]] ; then echo "SSH session" else echo "not SSH session" fi

who -m produces hostname and user associated with stdin, and in an SSH shell there is output, and none in a GUI terminal, which we can test for. who plus two dummy arguments will produce the same effect, e.g. who am i (very popular), who mom likes or who a b etc.

The top grab is my Rpi4 GUI, the bottom is an SSH login from my Windows PC using wsltty.

enter image description here

  • Would the down-voter care to comment, so I can amend the answer if necessary? Jan 7 '20 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.