# how to handle user prompt in privilege escalation

**URL:** <https://forum.ansible.com/t/how-to-handle-user-prompt-in-privilege-escalation/29891>\
**Category:** Ansible Project\
**Created:** [March 15, 2019, 5:45am UTC](https://forum.ansible.com/t/how-to-handle-user-prompt-in-privilege-escalation/29891 "2019-03-15T05:45:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hitesh\_shaha](https://avatars.discourse-cdn.com/v4/letter/h/3ab097/32.png) [@hitesh\_shaha](https://forum.ansible.com/u/hitesh_shaha)\
**Post date:** [March 15, 2019, 5:45am UTC](https://forum.ansible.com/t/how-to-handle-user-prompt-in-privilege-escalation/29891/1 "2019-03-15T05:45:02Z")

</div>

Hi Team,

we have developed playbook for oracle backup, but we are having big roadblock to use privilege escalation.  
we are using become\_user mentod for privilege escalation but in our env for security reason unix team has added script which prompts ticket number after switching user.  
so i can handle this in become\_user method.

existing setput in my env.

login to redhat server using my person id

username:hitesh  
…  
…connected.

> dzdo su - oracle  
> Please enter ticket number: INC00000

connected…

below is code which i have developed.

- name: Get oracle user from oracledb

shell: ps -ef| grep pmon|grep -v ‘grep’|grep {{ db\_list[0] }}|awk ‘{print $1}’

register: oracleuser

- name: Get the oracle\_group

shell: id -gn “{{ oracleuser.stdout\_lines[0] }}”

register: oraclegroup

- name : create permafrost directory

file :

path : /tmp/permafrost/

state: directory

mode: “u+rwx,g+rwx,o+rwx”

become: true

become\_user: “{{ oracleuser.stdout\_lines[0] }}”

#owner: “{{ oracleuser.stdout\_lines[0] }}”

#group: “{{ oraclegroup.stdout\_lines[0] }}”

- name: Copy script file to dbserver

copy:

src: runme.sh

dest: /tmp/permafrost/

mode: “u+rwx,g+rwx,o+rwx”

- name: Run the permafrost script for each databases

#ga\_db\_sid: “{{ item\_permafrost }}”

command: /bin/ksh runme.sh “{{ item\_permafrost }}” “{{ gac\_permafrost\_path }}” “{{ gac\_test\_mount\_only }}”

args:

chdir: /tmp/permafrost/

become: true

become\_user: “{{ oracleuser.stdout\_lines[0] }}”

register: permafrostscript\_output

with\_items: “{{ db\_list }}”

loop\_control:

loop\_var: item\_permafrost

**please help me on this.**

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 16, 2019, 6:56am UTC](https://forum.ansible.com/t/how-to-handle-user-prompt-in-privilege-escalation/29891/2 "2019-03-16T06:56:38Z")

</div>

> we have developed playbook for oracle backup, but we are having big  
> roadblock to use privilege escalation.  
> we are using become\_user mentod for privilege escalation but in our env for  
> security reason unix team has added script which prompts ticket number  
> after switching user.  
> so i can handle this in become\_user method.

Ansible will not handle this, Ansible is using sshpass and the string sshpass is looking for is hardcoded.

> existing setput in my env.
> 
> login to redhat server using my person id
> 
> username:hitesh  
> ..  
> ..connected.
> 
> \>dzdo su - oracle  
> Please enter ticket number: INC00000

One way to solve it would be to use the expect module.
