Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to setup XForwarding over ssh, but it fails. The same result happens whether I use the argument -X or -Y for ssh. The error I get.

a@ASUS-N53SM:~$ ssh -X -p 6623 pinker@
pinker@'s password: 
Last login: Sun Feb  2 18:42:08 2014 from
/usr/bin/xauth: (stdin):1:  bad display name "pinker-server:10.0" in "remove" command
/usr/bin/xauth: (stdin):2:  bad display name "pinker-server:10.0" in "add" command
xdpyinfo:  unable to open display "pinker-server:10.0".

In the client file ~/.ssh/config

ForwardX11 yes

In the client file /etc/ssh/ssh_config (comments removed).

Host *
ForwardX11 yes
ForwardX11Trusted yes
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes 
GSSAPIDelegateCredentials no

In the server file /etc/ssh/sshd_config (comments removed).

Port 6623
Port 6624
Port 6625
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
UsePrivilegeSeparation yes
KeyRegenerationInterval 3600
ServerKeyBits 768
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes
X11UseLocalhost no
AllowTcpForwarding yes

I found this similar Question, but none of the answers work.


On the server, I added to the file /etc/hosts.       pinker-server

On the server, I installed the package xbase-clients. On the ssh connection echo $DISPLAY outputs :0.0.

Now I'm getting a new error.

X11 connection rejected because of wrong authentication.
X11 connection rejected because of wrong authentication.
X11 connection rejected because of wrong authentication.
X11 connection rejected because of wrong authentication.
xdpyinfo:  unable to open display "pinker-server:10.0".
share|improve this question

On the remote machine, edit the file /etc/ssh/sshd_config. Change X11UseLocalhost to yes.

Source http://www.pclinuxos.com/forum/index.php?topic=109487.0

share|improve this answer
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – slm Dec 3 '14 at 1:51

Any time I run into an SSH issue I almost immediately re-run the command with more verbose messaging enabled. I like to use this technique to collect the log file on the server I'm running ssh from. If you need to get more details simply add more -v switches (the maximum is 3).

$ ssh -v user@remoteserver |& tee /path/to/sshv1.log
$ ssh -vv user@remoteserver |& tee /path/to/sshv2.log

X11 connection rejected because of wrong authentication.

This message is almost always indicative of a permissions problem with your .Xauthority file. You can either move the existing one out of the way temporarily or attempt to fix its ownership & permissions.

$ chown user:group ~/.Xauthority
$ chmod 0600 ~/.Xauthority

If the issue isn't resolved by either of these operations then you can attempt to diagnose the xauth magic cookies themselves.

as local user running ssh

$ xauth list
localhost/unix:13 MIT-MAGIC-COOKIE-1 c77169a6fa8139ea36f538e1c72e1b98

as pinker on server

$ xauth
Using authority file /home/pinker/.Xauthority

Then add the key manually:

xauth> add localhost/unix:13 MIT-MAGIC-COOKIE-1 c77169a6fa8139ea36f538e1c72e1b98


share|improve this answer

This error occurs when the remote machine doesn't know it's own hostname, or has an incorrect hostname associated with (NOTE: Not which should always resolve to localhost).

To correct it, ensure that the entry in /etc/hosts for matches the machine's FQDN and short hostname.

share|improve this answer
Thanks, that was exactly the case for me on my OpenBSD 5.9 (-current) desktop. – Iason Feb 18 at 16:47

I got most of this information from http://openvz.org/X_inside_VE#X_forwarding

Verify X in SSH

After login via SSH, verify that X forwarding is working by looking for the DISPLAY environmental variable:


The answer should be something like localhost:8.0

Make sure sshd allows X forwarding

Edit /etc/ssh/sshd_config and make sure it has X11Forwarding yes

If not, edit or add the line with X11Fordwarding then restart sshd:

service sshd restart (/etc/init.d/sshd restart is using CentOS 5)

Then log out and in again

Make sure xauth is set up

Make sure the xauth package has been installed. In Debian, this is part of the xbase-clients package.

It's still not working

In the question I am answering, the error message is this: /usr/bin/xauth: (stdin):1: bad display name "pinker-server:10.0" in "remove" command

One possible solution, suggested below, is making sure the relevant line in sshd_config looks like this:

X11UseLocalhost yes
share|improve this answer
It looks like we might be getting closer to the solution? I have updated the info above. Thank you. – Rucent88 Feb 3 '14 at 1:08
It's generally a bad idea to add a hostname to – slm Feb 3 '14 at 2:18
I've edited the answer to reflect that. – samiam Feb 3 '14 at 4:33

Bumped into this problem after Gentoo upgrade. This page is the first google result for 'add display name unix in add command'. None of the solutions described here helped. The workaround is written in the debian bug description (second link in the fore-mentioned google search page):

sethostname any-name-here

after execution of 'sethostname vvk' I can log in with X-forwarding as before. This answer is typed from the browser which is being run in the very first proper shell logged in on remote server.

share|improve this answer

For me works like a charm sshd_config

    Protocol 2
AuthorizedKeysFile  .ssh/authorized_keys
KerberosAuthentication yes
KerberosOrLocalPasswd yes
KerberosTicketCleanup yes
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
UsePAM yes
X11Forwarding yes
X11UseLocalhost yes
UsePrivilegeSeparation yes      # Default for new installations.
Banner /etc/issue.net
Subsystem   sftp    /usr/libexec/openssh/sftp-server
Ciphers aes256-ctr,aes192-ctr,aes128-ctr,arcfour256
MACs hmac-sha2-256,hmac-sha2-512,hmac-sha1,umac-64@openssh.com,hmac-ripemd160


Host *
   ForwardX11trusted yes
   GSSAPIAuthentication yes
   GSSAPIDelegateCredentials yes

And use

ssh -X remotehost

of course Xorg server must be installed full(using groupinstall,good idea)

share|improve this answer
typical sshd config, nothing special. – Vladimir Kunschikov Sep 27 '15 at 4:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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