aza*_*zat 15 ssh x11 x11forwarding
我有一台家用和工作电脑,家用电脑有一个静态 IP 地址。
如果我从我的工作计算机 ssh 到我的家用计算机,ssh 连接有效,但不显示 X11 应用程序。
在我/etc/ssh/sshd_config
家:
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
Run Code Online (Sandbox Code Playgroud)
在工作中,我尝试了以下命令:
xhost + home HOME_IP
ssh -X home
ssh -X HOME_IP
ssh -Y home
ssh -Y HOME_IP
Run Code Online (Sandbox Code Playgroud)
我/etc/ssh/ssh_config
在工作:
Host *
ForwardX11 yes
ForwardX11Trusted yes
Run Code Online (Sandbox Code Playgroud)
我~/.ssh/config
在工作:
Host home
HostName HOME_IP
User azat
PreferredAuthentications password
ForwardX11 yes
Run Code Online (Sandbox Code Playgroud)
我~/.Xauthority
在工作:
-rw------- 1 azat azat 269 Jun 7 11:25 .Xauthority
Run Code Online (Sandbox Code Playgroud)
我~/.Xauthority
在家里:
-rw------- 1 azat azat 246 Jun 7 19:03 .Xauthority
Run Code Online (Sandbox Code Playgroud)
但它不起作用
在我与家建立 ssh 连接后:
$ echo $DISPLAY
localhost:10.0
$ kate
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.
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.
kate: cannot connect to X server localhost:10.0
Run Code Online (Sandbox Code Playgroud)
我iptables
在家里使用,但我已经允许端口 22。根据我所读到的,这就是我所需要的。
更新。
和-vvv
... debug2:回调开始 debug2:x11_get_proto:/usr/bin/xauth 列表:0 2>/dev/null debug1:使用身份验证欺骗请求 X11 转发。 debug2:通道 1:请求 x11-req 确认 1 调试 2:client_session2_setup:id 1 debug2: fd 3 设置 TCP_NODELAY debug2:通道 1:请求 pty-req 确认 1 ...
尝试启动时kate
:
debug1: client_input_channel_open: ctype x11 rchan 2 win 65536 max 16384 debug1:client_request_x11:来自 127.0.0.1 55486 的请求 debug2: fd 8 设置 O_NONBLOCK debug3: fd 8 是 O_NONBLOCK 调试 1:通道 2:新 [x11] debug1:确认 x11 debug2:X11 连接使用不同的认证协议。 由于身份验证错误,X11 连接被拒绝。 debug2: X11 拒绝 2 i0/o0 调试 2:通道 2:读取失败 debug2:通道 2:close_read debug2:通道 2:输入开路 -> 漏极 debug2:通道 2:ibuf 为空 debug2:通道 2:发送 eof debug2:通道 2:输入漏 -> 关闭 debug2:通道 2:写入失败 调试 2:通道 2:close_write debug2:通道 2:输出打开 -> 关闭 debug2: X11 关闭 2 i3/o3 debug2:通道 2:发送关闭 debug2:通道 2:rcvd 关闭 debug2:通道 2:已死 debug2:通道 2:垃圾收集 调试 1:通道 2:空闲:x11,n 通道 3 debug3:通道 2:状态:以下连接已打开: #1 客户端会话(t4 r0 i0/0 o0/0 fd 5/6 cc -1) #2 x11 (t7 r2 i3/0 o3/0 fd 8/8 cc -1) # 同上重复约7次 凯特:无法连接到 X 服务器 localhost:10.0
UPD2
请提供您的 Linux 发行版和版本号。
您是否使用 X 的默认 GNOME 或 KDE 环境或您自己定制的其他环境?
azat:~$ kded4 -version Qt:4.7.4 KDE 开发平台:4.6.5 (4.6.5) KDE 守护进程:$Id$
您是从终端窗口直接在命令行上调用 ssh 吗?
你用的是什么终端?xterm、gnome-terminal 还是?
你是如何启动在X环境下运行的终端的?从菜单?热键?或者 ?
来自终端模拟器`yakuake` 手动按“Ctrl + N”并编写命令
您可以从 ssh -X 失败的同一终端窗口运行 xeyes 吗?
`xeyes` - 未安装 但是 `kate` 或其他 kde 应用程序正在运行
您是否以登录 X 会话的同一用户身份调用 ssh 命令?
From the same user
UPD3
我也下载了ssh
源代码,并使用debug2()
write 为什么报告版本不同
它看到一些 cookie,其中一个是空的,另一个是MIT-MAGIC-COOKIE-1
aza*_*zat 22
ssh X 转发不起作用的原因是我有一个/etc/ssh/sshrc
配置文件。
sshd(8)
手册页的末尾指出:
如果
~/.ssh/rc
存在,运行它;否则如果/etc/ssh/sshrc
存在,运行它;否则运行 xauth
因此,我将以下命令添加到/etc/ssh/sshrc
服务器端(也来自 sshd 手册页):
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
Run Code Online (Sandbox Code Playgroud)
它有效!
归档时间: |
|
查看次数: |
48343 次 |
最近记录: |