1

I have two computers: PC1 and PC2. Both are running identical installation of Debian Wheezy with latest updates. The installation on PC2 were taken from PC1 using tar. The only differences between PC1 and PC2 are grub entries, hostname, contents of /etc/hosts and IP Address. SSHD configuration of both computers are identical:

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

#AddressFamily inet

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts                                                                                                             
RhostsRSAAuthentication no                                                                                                                                                          
# similar for protocol version 2                                                                                                                                                    
HostbasedAuthentication no                                                                                                                                                          
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication                                                                                                       
#IgnoreUserKnownHosts yes                                                                                                                                                           

# To enable empty passwords, change to yes (NOT RECOMMENDED)                                                                                                                        
PermitEmptyPasswords no                                                                                                                                                             

# Change to yes to enable challenge-response passwords (beware issues with                                                                                                          
# some PAM modules and threads)                                                                                                                                                     
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

I can ssh from PC2 to PC1 and run GUI programs just fine. But I cannot run GUI programs remotely on PC2 from any computer (including PC2 itself). Here's the output I got when trying to run xterm after ssh -Xvvv localhost on PC2:

user@pc2:~$ xterm
debug1: client_input_channel_open: ctype x11 rchan 3 win 65536 max 16384
debug1: client_request_x11: request from 127.0.0.1 42667
debug2: fd 7 setting O_NONBLOCK
debug3: fd 7 is O_NONBLOCK
debug1: channel 1: new [x11]
debug1: confirm x11
debug2: X11 connection uses different authentication protocol.
X11 connection rejected because of wrong authentication.
debug2: X11 rejected 1 i0/o0
debug2: channel 1: read failed
debug2: channel 1: close_read
debug2: channel 1: input open -> drain
debug2: channel 1: ibuf empty
debug2: channel 1: send eof
debug2: channel 1: input drain -> closed
debug2: channel 1: write failed
debug2: channel 1: close_write
debug2: channel 1: output open -> closed
debug2: X11 closed 1 i3/o3
debug2: channel 1: send close
debug2: channel 1: rcvd close
debug2: channel 1: is dead
debug2: channel 1: garbage collecting
debug1: channel 1: free: x11, nchannels 2
debug3: channel 1: status: The following connections are open:
  #0 client-session (t4 r0 i0/0 o0/0 fd 4/5 cc -1)
  #1 x11 (t7 r3 i3/0 o3/0 fd 7/7 cc -1)

xterm: Xt error: Can't open display: pc2:11.0

Permissions and ownership of ~/.Xauthority look normal:

user@pc2:~$ ls -l ~/.Xauthority 
-rw------- 1 user user 301 Aug 27 13:49 /home/user/.Xauthority

I've been trying to fix this problem for hours by googling but don't seem to be getting anywhere. I need your help.

1 Answer 1

5

See if you have a file ~/.ssh/rc or /etc/ssh/sshrc on the server. According to this question, if one of those scripts exists, then sshd will run it during session startup, and the script is responsible for calling xauth to set up X11 authentication. If neither of the files exists, then sshd calls xauth directly. It's possible that you have one of those files on the remote server, and it's not doing its job correctly.

The OpenSSH sshd man page has an example of the shell code which the rc script should run to set up xauth:

If X11 forwarding is in use, it will receive the "proto cookie" pair in its standard input (and DISPLAY in its environment). The script must call xauth(1) because sshd will not run xauth automatically to add X11 cookies.

if read proto cookie && [ -n "$DISPLAY" ]; then 
    if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then 
        # X11UseLocalhost=yes 
        echo add unix:`echo $DISPLAY | 
            cut -c11-` $proto $cookie 
    else 
        # X11UseLocalhost=no 
        echo add $DISPLAY $proto $cookie 
    fi | xauth -q - 
fi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .