2

I want to control a no GUI Debian server by an X11 connection via ssh from Ubuntu desktop. From everything I read and watched it should work like a charm on Linux distros but it doesn't.

# The debian /etc/ssh/sshd_config:

...
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
...

I did restart the sshd on debian after saving.
When I connect: ssh -X debian from Ubuntu (I have a config with port and user), after establishing connection and typing: gedit I get the following error:

user@debian:~$ gedit
Unable to init server: Could not connect: Connection refused

(gedit:26888): Gtk-WARNING **: 17:00:04.268: cannot open display: 

I have also openssh-server installed on Ubuntu with the same X11 configuration. I don't know if that is necessary but I tried anyway.

I have no clue what is needed for X11 to work between two Linux distros, from what I understand in X11 the roles are oposite and my Ubuntu desktop is now running (is supposed to run) an X11 server software which is supposed to come with ssh so I don't need to install anything and the Debian server is an X11 client.

Please help me connect and run GUI programs.

EDIT 1:

user@ubuntu:~$ ssh -X -vvv debian

OpenSSH_8.3p1 Ubuntu-1ubuntu0.1, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /home/*******/.ssh/config
debug1: /home/*******/.ssh/config line 1: Applying options for debiando
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolving ********* port *****
debug2: ssh_connect_direct
debug1: Connecting to ************************
debug1: Connection established.
debug1: identity file /home/*******/.ssh/***_id_rsa type 0
debug1: identity file /home/*******/.ssh/***_id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.3p1 Ubuntu-1ubuntu0.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.9p1 Debian-10+deb10u2
debug1: match: OpenSSH_7.9p1 Debian-10+deb10u2 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to *****************
debug3: put_host_port: *******************
debug3: hostkeys_foreach: reading file "/home/*********/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/********/.ssh/known_hosts:5
debug3: load_hostkeys: loaded 1 keys from ************
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:NvDOG/B9cRs6ML8cvw8BZ/Kv68dy52FwLKfYR69e4DA
debug3: put_host_port: **************
debug3: put_host_port: *********************
debug3: hostkeys_foreach: reading file "/home/*******/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/*******/.ssh/known_hosts:5
debug3: load_hostkeys: loaded 1 keys from **************
debug3: hostkeys_foreach: reading file "/home/*******/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/*******/.ssh/known_hosts:6
debug3: load_hostkeys: loaded 1 keys from *********************
debug1: Host '**************' is known and matches the ECDSA host key.
debug1: Found key in /home/*******/.ssh/known_hosts:5
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/*******/.ssh/****_id_rsa RSA SHA256:OmiK3okiaARnd7XRw4d+y/LUaPREzcujUo4C4Ac+Hp4 explicit agent
debug1: Will attempt key: *******@KK-flash RSA SHA256:O6QLIsdS+t9UO0IyAsk14PaM+RQocYYcXlxf6CuK7UE agent
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/*******/.ssh/*****_id_rsa RSA SHA256:OmiK3okiaARnd7XRw4d+y/LUaPREzcujUo4C4Ac+Hp4 explicit agent
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: /home/*******/.ssh/****_id_rsa RSA SHA256:OmiK3okiaARnd7XRw4d+y/LUaPREzcujUo4C4Ac+Hp4 explicit agent
debug3: sign_and_send_pubkey: RSA SHA256:OmiK3okiaARnd7XRw4d+y/LUaPREzcujUo4C4Ac+Hp4
debug3: sign_and_send_pubkey: signing using rsa-sha2-512 SHA256:OmiK3okiaARnd7XRw4d+y/LUaPREzcujUo4C4Ac+Hp4
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to ****************************
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: exec
debug3: receive packet: type 80
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug3: receive packet: type 4
debug1: Remote: /home/*******/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug3: receive packet: type 4
debug1: Remote: /home/*******/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: x11_get_proto: /usr/bin/xauth  list :1 2>/dev/null
debug1: Requesting X11 forwarding with authentication spoofing.
debug2: channel 0: request x11-req confirm 1
debug3: send packet: type 98
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug3: send packet: type 98
debug1: Sending environment.
debug3: Ignored env SHELL
debug3: Ignored env SESSION_MANAGER
debug3: Ignored env QT_ACCESSIBILITY
debug3: Ignored env COLORTERM
debug3: Ignored env XDG_CONFIG_DIRS
debug3: Ignored env XDG_MENU_PREFIX
debug3: Ignored env GNOME_DESKTOP_SESSION_ID
debug3: Ignored env MANDATORY_PATH
debug1: Sending env LC_ADDRESS = pl_PL.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env GNOME_SHELL_SESSION_MODE
debug1: Sending env LC_NAME = pl_PL.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env XMODIFIERS
debug3: Ignored env DESKTOP_SESSION
debug1: Sending env LC_MONETARY = pl_PL.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env SSH_AGENT_PID
debug3: Ignored env GTK_MODULES
debug3: Ignored env PWD
debug3: Ignored env LOGNAME
debug3: Ignored env XDG_SESSION_DESKTOP
debug3: Ignored env XDG_SESSION_TYPE
debug3: Ignored env GPG_AGENT_INFO
debug3: Ignored env XAUTHORITY
debug3: Ignored env WINDOWPATH
debug3: Ignored env HOME
debug3: Ignored env USERNAME
debug3: Ignored env IM_CONFIG_PHASE
debug1: Sending env LC_PAPER = pl_PL.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env LS_COLORS
debug3: Ignored env XDG_CURRENT_DESKTOP
debug3: Ignored env VTE_VERSION
debug3: Ignored env GNOME_TERMINAL_SCREEN
debug3: Ignored env QT_DEVICE_PIXEL_RATIO
debug3: Ignored env LESSCLOSE
debug3: Ignored env XDG_SESSION_CLASS
debug3: Ignored env TERM
debug1: Sending env LC_IDENTIFICATION = pl_PL.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env DEFAULTS_PATH
debug3: Ignored env LESSOPEN
debug3: Ignored env LIBVIRT_DEFAULT_URI
debug3: Ignored env USER
debug3: Ignored env GNOME_TERMINAL_SERVICE
debug3: Ignored env DISPLAY
debug3: Ignored env SHLVL
debug1: Sending env LC_TELEPHONE = pl_PL.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env PT7HOME
debug3: Ignored env QT_IM_MODULE
debug1: Sending env LC_MEASUREMENT = pl_PL.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env XDG_RUNTIME_DIR
debug1: Sending env LC_TIME = pl_PL.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env XDG_DATA_DIRS
debug3: Ignored env PATH
debug3: Ignored env GDMSESSION
debug3: Ignored env DBUS_SESSION_BUS_ADDRESS
debug1: Sending env LC_NUMERIC = pl_PL.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env GOPATH
debug3: Ignored env _
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug3: receive packet: type 4
debug1: Remote: No xauth program; cannot forward X11.
debug3: receive packet: type 100
debug2: channel_input_status_confirm: type 100 id 0
X11 forwarding request failed on channel 0
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Linux debianserver 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Jun 16 17:19:01 2021 from 83.4.50.208
kDeb:~$ debug2: client_check_window_change: changed
debug2: channel 0: request window-change confirm 0
debug3: send packet: type 98
debug2: client_check_window_change: changed
debug2: channel 0: request window-change confirm 0
debug3: send packet: type 98
3
  • When you get an error like the one from gedit, what is the value of your DISPLAY environment variable? Do you have anything in the .bashrc or similar files on the server which modifies the DISPLAY variable?
    – Kenster
    Commented Jun 16, 2021 at 19:15
  • Nothing is shown. I did 'echo $DISPLAY'
    – Kacper
    Commented Jun 16, 2021 at 19:16
  • If DISPLAY isn't set to anything, then either ssh isn't forwarding X, or something is interfering with the value of the environment variable. Try running ssh with the "-vvv" option to print debugging output, then edit your question to include the debugging output. That should show whether ssh is trying to forward X or not.
    – Kenster
    Commented Jun 16, 2021 at 19:18

2 Answers 2

2

Answer:
Install xauth on both sides: sudo apt-get install xauth.

To find what is wrong turn on debugging with ssh it is done by:
using switches -v, -vv and -vvv where the last gives the most in-depth info.

By using the first switch at the end of debug messages I found:
debug1: Remote: No xauth program; cannot forward X11. Which was the answer.

0

OS: Ubuntu 22.04

It was because xauth could not write to my .Xauthority,

If you see a message similar to /usr/bin/xauth: unable to rename authority file /home/user/.Xauthority, use /home/user/.Xauthority-n Simply delete the existing file rmdir ~/.Xauthority

and create a new one touch ~/.Xauthority

Hope it helps someone

You must log in to answer this question.

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