使用 sudo (root用户) 无法使用 X11 转发的问题: X11 connection rejected because of wrong authentication.

由于要远程使用Mininet,而 mininet 是超级用户 sudo 的权限,X11 权限设置里只能用普通用户,所以无法在 niminet 里使用 xterm。

简单点说,使用 X11 转发进行 ssh 连接,普通用户使用 GUI 界面,例如 xterm 时,没有问题。

但是如果加上 sudo xterm,就报权限错误了。

wu@wu-ubuntu:~$ sudo xterm
X11 connection rejected because of wrong authentication.
Warning: This program is an suid-root program or is being run by the root user.
The full text of the error or warning message cannot be safely formatted
in this environment. You may get a more descriptive message by running the
program as a non-root user or by removing the suid bit on the executable.
xterm: Xt error: Can't open display: %s

因为 X11 连接属于连接到远程 SSH 服务器时用来登录的用户,而不是 root 用户,在 Linux 中不被允许。

查了几个小时资料,终于解决了,参考这篇博客

需要添加到 Xauthority,运行以下命令:[wu]改为自己的用户名。

sudo xauth add $(xauth -f ~[wu]/.Xauthority list|tail -1)

然后 root 用户也能进行 X11 转发了。

不过这个方法,每次重启终端都需要输入一次。

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值