Thursday, October 26, 2017

Unix (Solaris) display forwarding after user switch (su)

Using X forward via SSH, Xming client running locally on Windows box. After login to SSH with your preferred tool (Putty or SSH Secure Shell) X applications do work, but they stop working after you switch to another user.
My objective was to run Oracle Installer without having root access or Oracle user via SSH only. User is not part of DBA group and new Oracle user (ora12213) does not have X access.

bash-4.1$ xclock
Error: Can't open display: localhost:10.0

Found plenty of resources online, but all of them missing something, here is a full list of steps to make it work.

1) setup your SSH tool for X forwarding (settings, checkbox)
2) save settings and restart the tool and connection (it appears that setting is only activated after a new connection or window is opened)
3) test xclock

bash-4.1$ xclock

4) echo these variables:

-bash-4.1$ xauth list
solserv102/unix:10  MIT-MAGIC-COOKIE-1  2359b71c685cf706bf4dec49e4136558
-bash-4.1$ echo $DISPLAY
localhost:10.0

5) do the user switch with parameters, minus is essential. Username is "ora12213":

-bash-4.1$ sudo su - ora12213
Oracle Corporation      SunOS 5.11      11.2    March 2015

6) export the variables listed above, looks like error can be ignored. In most of the tested examples "xauth add" part was not working, but after user switching with su, it looks like it okayed:

-bash-4.1$ xauth add solserv102/unix:10  MIT-MAGIC-COOKIE-1  2359b71c685cf706bf4dec49e4136558
xauth:  file /export/home/ora12213/.Xauthority does not exist
-bash-4.1$ export DISPLAY=localhost:10.0

7) test the X, should be working just fine.

-bash-4.1$ xclock

BONUS

Run the Solaris installer executable (it was downloaded, unzipped, moved to /stage_oracle folder, owned by DBA group):

-bash-4.1$ cd /stage_oracle/
-bash-4.1$ ./fmw_12.2.1.3.0_ohs_solaris_sparc64.bin
Launcher log file is /var/tmp/OraInstall2017-10-26_09-46-21AM/launcher2017-10-26_09-46-21AM.log.
Checking if CPU speed is above 300 MHz.   Actual 3600 MHz    Passed
Checking monitor: must be configured to display at least 256 colors.   Actual 16777216    Passed
Checking swap space: must be greater than 512 MB.   Actual 85678 MB    Passed
Checking if this platform requires a 64-bit JVM.   Actual 64    Passed
Checking temp space: must be greater than 300 MB.   Actual 1672 MB    Passed
Preparing to launch the Oracle Universal Installer from /var/tmp/OraInstall2017-10-26_09-46-21AM
Log: /var/tmp/OraInstall2017-10-26_09-46-21AM/install2017-10-26_09-46-21AM.log

Voila




No comments:

Post a Comment