OCI: How to Use sudo/su in Combination with xhost and x11forwarding
Applies to
Oracle Cloud Infrastructure
Linux OS - Version Oracle Linux 7.0 to Oracle Linux 7.9 [Release OL7 to OL7U9]
Linux x86-64
Goal
How to use sudo/su in combination with x11forwarding on Oracle Linux 7
Solution
- As root, install necessary packages
$ yum install xclock xorg-x11-xauth
- Login as user "opc" and create an export for user "oracle"
$ mkdir .xauth $ echo oracle > .xauth/export $ xauth list $DISPLAY testserver01/unix:10 MIT-MAGIC-COOKIE-1 8ae3testc90ef1test140a6ccbf64c1 $ echo $DISPLAY localhost:10.0
- Then login to user "oracle"
$ sudo su - oracle
or
$ su - oracle
- As user "oracle" do If "/home/oracle/.Xauthority" does not exist, the following error is shown
Tagged:
0