sábado, março 30, 2019

How to keep X11 display after su or sudo

https://blog.mobatek.net/post/how-to-keep-X11-display-after-su-or-sudo/

You can also use a single (magic) command in order to achieve this!

For instance, here is a simple scenario:
  • I start a SSH session to remote server “Server1” with user “john”
  • In this session, I perform a “su -” command in order to become “root”
  • If I run “xclock”, the following error occurs:
MobaXterm X11 proxy: Authorisation not recognised
Error: Can’t open display: localhost:10.0
I just have to execute the following command in order to retrieve my display and make “xclock” work:
xauth add $(xauth -f ~john/.Xauthority list|tail -1)

We hope this will help you if you need to have a working X11 display through SSH after becoming root.
Get your $DISPLAY and export it if you changed to root user. Check if they are the same, it has to be!

Nenhum comentário: