简单的问题:为了安全使用更安全ssh -X
还是ssh -Y
?据我所知 ssh -Y 是 X11Trusted,因此不再进行任何控制,因此出于安全原因最好使用 -X 。你觉得呢?我通常使用 -Y,因为如果我使用 -X 选项,当我在目标计算机上执行 ssh 时,我会看到此消息。
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Run Code Online (Sandbox Code Playgroud)
我通过局域网连接一台机器。
我自己回答。也许这个ssh -X
选择更安全。因为需要两种类型的身份验证:ssh(密码、kerberos 或公钥)和 x11(xauth、xhost)身份验证。当我们使用ssh -Y
所谓的“受信任”时,我们信任主机并绕过 X11 身份验证,因此我们不需要使用命令 xhost。所以在我看来ssh -X
更安全,只有一个问题:使用最新版本的 ssh 似乎给出了我所做的这个问题
\ssh -vvv -X myhost
Run Code Online (Sandbox Code Playgroud)
我得到了这两个错误
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
debug2: client_x11_get_proto: xauth command: /usr/bin/xauth -f /tmp/ssh-KYHfkmGN25fa/xauthfile generate :0.0 MIT-MAGIC-COOKIE-1 untrusted timeout 1260 2>/dev/null
Run Code Online (Sandbox Code Playgroud)
当我尝试直接运行 xauth 命令时出现此错误
/usr/bin/xauth -f /tmp/ssh-KYHfkmGN25fa/xauthfile generate :0.0 MIT-MAGIC-COOKIE-1 untrusted timeout 1260
/usr/bin/xauth: error in locking authority file /tmp/ssh-KYHfkmGN25fa/xauthfile
Run Code Online (Sandbox Code Playgroud)
解决方法:编辑 ssh_config 并启用这些行
Host *
ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes
Run Code Online (Sandbox Code Playgroud)
ssh -X 现在工作正常,但只有一个问题我尝试禁用访问
xhost -
Run Code Online (Sandbox Code Playgroud)
并且运行 ssh -X 仍然接受主机!所以我认为 ForwardX11Trusted yes 覆盖 ForwardX11 yes
编辑 ssh_config
Host *
ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted no
Run Code Online (Sandbox Code Playgroud)
和 ssh -X 不起作用。所以问题仍然悬而未决。