{"id":1454,"date":"2017-09-13T22:12:57","date_gmt":"2017-09-13T20:12:57","guid":{"rendered":"http:\/\/www.ora-solutions.net\/web\/?p=1454"},"modified":"2017-09-13T22:12:57","modified_gmt":"2017-09-13T20:12:57","slug":"cloud-control-privilege-delegation-so-you-dont-have-the-oracle-root-password","status":"publish","type":"post","link":"https:\/\/www.ora-solutions.net\/web\/2017\/09\/13\/cloud-control-privilege-delegation-so-you-dont-have-the-oracle-root-password\/","title":{"rendered":"Cloud Control &#8211; Privilege Delegation &#8211; so you don\u00b4t have the oracle \/ root password?"},"content":{"rendered":"<p>Quite frequently in database environments, security policies dictate that only personalized logons to Unix \/ Linux are allowed and that from there, one has to &#8220;sudo&#8221; to change to the oracle account. While this adds an additional layer of security, it makes administration a little more complicated.<\/p>\n<p>Oracle Enterprise Manager &#8211; Cloud Control has a feature, which allows to cope with such a sudo environment. The feature is called &#8220;Privilege Delegation&#8221;. This post describes how to set it up and for what it can be used.<\/p>\n<ol>\n<li><strong>Setup of &#8220;sudo&#8221; by the root account<\/strong><\/li>\n<p>In order to use privilege delegation, specific sudo rules have to be defined. This rule normally already exists:<\/p>\n<pre lang=\"TEXT\" line=\"1\">\r\nmdecker ALL=(root) NOPASSWD:\/bin\/su - oracle\r\n<\/pre>\n<p>In addition to this one, two additional rules are required. If only sudo to &#8220;oracle&#8221; is required, then only the first line is needed.<\/p>\n<pre lang=\"TEXT\" line=\"1\">\r\nmdecker ALL=(oracle) SETENV:\/u01\/app\/oracle\/cloud\/agent\/sbin\/nmosudo *\r\nmdecker ALL=(root) SETENV:\/u01\/app\/oracle\/cloud\/agent\/sbin\/nmosudo *\r\n<\/pre>\n<li><strong>Setup of Privilege Delegation in Cloud Control<\/strong><\/li>\n<p>Go to Setup -> Security -> Privilege Delegation.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-21.44.55.png\" alt=\"\" width=\"332\" height=\"305\" class=\"alignnone size-full wp-image-1460\" srcset=\"https:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-21.44.55.png 332w, https:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-21.44.55-300x276.png 300w\" sizes=\"auto, (max-width: 332px) 100vw, 332px\" \/><br \/>\nThen you can either set it globally via template or individually for each host. This depends mainly on the path to &#8220;sudo&#8221; binary in the operating system. Then you choose &#8220;sudo&#8221; and provide the path to the sudo binary on your operating system (bash$ which sudo). The required parameters are then appended:  \/usr\/bin\/sudo -E -u %RUNAS% %COMMAND%<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-21.47.41.png\" alt=\"\" width=\"330\" height=\"211\" class=\"alignnone size-full wp-image-1462\" srcset=\"https:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-21.47.41.png 330w, https:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-21.47.41-300x192.png 300w\" sizes=\"auto, (max-width: 330px) 100vw, 330px\" \/><\/p>\n<li><strong>The next step is to configure a Named Credential.<\/strong><\/li>\n<p>If you are in a team of administrators, then each administrator should have his own account to log on to Cloud Contol and avoid using &#8220;sysman&#8221; user. For obvious reasons, each administrator has to create his own &#8220;named credential&#8221; (Setup->Security->Named Credential), because it contains his personalized username and password.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-21.56.20.png\" alt=\"\" width=\"512\" height=\"399\" class=\"alignnone size-full wp-image-1467\" srcset=\"https:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-21.56.20.png 512w, https:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-21.56.20-300x234.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n<p>Here you provide your personalized credentials (username\/password) and specify that sudo should be used to change to &#8220;oracle&#8221;. <\/p>\n<li><strong>Lastly, verify that it works as desired.<\/strong><\/li>\n<p>Go to &#8220;Targets&#8221; -> &#8220;Host&#8221; and click &#8220;Run Host Command&#8221;.  Then give the command to run, e.g. &#8220;id -a&#8221;, and then add a named credential as well as a specific host and click &#8220;Run&#8221;.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-22.03.16.png\" alt=\"\" width=\"835\" height=\"306\" class=\"alignnone size-full wp-image-1471\" srcset=\"https:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-22.03.16.png 835w, https:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-22.03.16-300x110.png 300w\" sizes=\"auto, (max-width: 835px) 100vw, 835px\" \/><br \/>\nIf all is well, then you will get this output showing you the id of user oracle.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-22.04.07.png\" alt=\"\" width=\"579\" height=\"38\" class=\"alignnone size-full wp-image-1473\" srcset=\"https:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-22.04.07.png 579w, https:\/\/www.ora-solutions.net\/web\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-13-at-22.04.07-300x20.png 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/>\n<\/ol>\n<p>How does this work behind the scenes? The agent java process spawns a process &#8220;nmo&#8221;. This process was granted SETUID root Privileges by executing $ORACLE_HOME\/root.sh at the time of agent deployment. This executable is calling &#8220;sudo&#8221; to run command &#8220;nmosudo&#8221; as user oracle with the &#8220;payload&#8221; command, which the user wanted to execute. <\/p>\n<pre lang=\"text\" line=\"1\">\r\nroot   14595  3149  0 14:23 pts\/0    00:00:00 \/u01\/app\/oracle\/cloud\/agent\/sbin\/nmo\r\nroot   14598 14595  0 14:23 pts\/1    00:00:00   \/usr\/bin\/sudo -p ###AGENT-PDP-PASSWORD-PROMPT### -E -u oracle \/u01\/app\/oracle\/cloud\/agent\/sbin\/nmosudo DEFAULT_PLUGIN DEFAULT_FUNCTIONALITY DEFAULT_SUBACTION DEFAULT_ACTION \/bin\/sh -c id -a\r\noracle 14602 14598  0 14:23 pts\/1    00:00:00     sleep 300\r\n<\/pre>\n<p>The linux logfile \/var\/log\/secure will contain this messages. It can be seen that the personal user &#8220;mdecker&#8221; was running the command &#8220;nmosudo&#8221; with the payload command &#8220;id -a&#8221; as attribute.<\/p>\n<pre lang=\"text\" line=\"1\">\r\nSep 13 22:03:59 xxx sudo:  mdecker : TTY=pts\/2 ; PWD=\/u01\/app\/oracle\/cloud\/agent\/agent_inst\/sysman\/emd ; USER=oracle ; COMMAND=\/u01\/app\/oracle\/cloud\/agent\/sbin\/nmosudo DEFAULT_PLUGIN DEFAULT_FUNCTIONALITY DEFAULT_SUBACTION DEFAULT_ACTION \/bin\/sh -c id -a\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Quite frequently in database environments, security policies dictate that only personalized logons to Unix \/ Linux are allowed and that from there, one has to &#8220;sudo&#8221; to change to the oracle account. While this adds an additional layer of security, it makes administration a little more complicated. Oracle Enterprise Manager &#8211; Cloud Control has a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[6,1],"tags":[],"class_list":["post-1454","post","type-post","status-publish","format-standard","hentry","category-oracle-enterprise-manager","category-uncategorized"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ora-solutions.net\/web\/wp-json\/wp\/v2\/posts\/1454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ora-solutions.net\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ora-solutions.net\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ora-solutions.net\/web\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ora-solutions.net\/web\/wp-json\/wp\/v2\/comments?post=1454"}],"version-history":[{"count":17,"href":"https:\/\/www.ora-solutions.net\/web\/wp-json\/wp\/v2\/posts\/1454\/revisions"}],"predecessor-version":[{"id":1477,"href":"https:\/\/www.ora-solutions.net\/web\/wp-json\/wp\/v2\/posts\/1454\/revisions\/1477"}],"wp:attachment":[{"href":"https:\/\/www.ora-solutions.net\/web\/wp-json\/wp\/v2\/media?parent=1454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ora-solutions.net\/web\/wp-json\/wp\/v2\/categories?post=1454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ora-solutions.net\/web\/wp-json\/wp\/v2\/tags?post=1454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}