set-up X11 Forwarding over ssh

和自甴很熟 提交于 2019-11-28 19:35:23

on the server

vim /etc/ssh/sshd_config

AllowAgentForwarding yes
AllowTcpForwarding yes
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no

Restart the sshd daemon:

sudo service sshd restart
# or
sudo /etc/init.d/ssh restart
# or whatever way of restarting your box services works on your distro...

yum -y update xauth
apt-get -y update xauth
yum -y install xauth
apt-get -y install xauth

Now exit from the server:

exit

set local the DISPLAY env var:

export DISPLAY=:0.0

and invoke a trusted SSH connection with the server:

ssh -Y $ssh_user@$ssh_server

Verify success with a graphical app. Install an app supporting X11 forwarding, if needed. As an example:

  yum -y install xclock

and Action !!!

  for i in {1..3} ; do bash -c "xclock &" ; done ;

Whenever I had this problem it was almost always about following two options, I think you should set them as below before making any further changes on your configuration like setting DISPLAY, etc.

X11Forwarding yes
X11UseLocalhost no
phil_w

ssh should set the DISPLAY automatically. usual suspects: missing "X11Forwarding yes" in /etc/ssh/sshd_config

To debug you can run verbose mode on the client and server and you may notice something : try on the "server" side (debug mode, no daemon)

$ /usr/sbin/sshd -d -p 222

on the "client":

$ ssh -v -Y phil@192.168.0.14 -p 222

Once in a while I meet an odd thing, like 'missing xauth' ...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!