# Change credentials between hosts

**URL:** <https://forum.ansible.com/t/change-credentials-between-hosts/26251>\
**Category:** Ansible Project\
**Created:** [December 11, 2017, 7:36pm UTC](https://forum.ansible.com/t/change-credentials-between-hosts/26251 "2017-12-11T19:36:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Phillips](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@Kevin\_Phillips](https://forum.ansible.com/u/Kevin_Phillips)\
**Post date:** [December 11, 2017, 7:36pm UTC](https://forum.ansible.com/t/change-credentials-between-hosts/26251/1 "2017-12-11T19:36:03Z")

</div>

I have another unique use case I’m trying to work through with Ansible that I just can’t seem to get working.

I’ve got a play that configures a service on a system which depends on a change being made to another server (ie: log in to machine A to configure service, log in to machine B to allow machine A to connect to it, then log back into machine A to activate the service). Further, the credentials used to (a) authenticate to the two machines and (b) to escalate / become / sudo for those users are different between the two machines.

So I’m looking for a way to do something like this:

1. connect to machine A using user A (ie: without a pasword, using SSH authorized keys)
2. escalate (ie: sudo / become) on machine A to set up a new service
3. connect to machine B using user B using the password for user B
4. escalate (ie: sudo / become) on machine B (NOTE: The sudo password for user A != sudo password for user B)
5. change permissions on machine B so machine A can access resources on this system
6. reconnect to machine A as user A and launch service (which, in turn, needs access to resources on machine B)

For the life of me I can’t seem to find a good way to swizzle the credentials and SSH parameters for users between hosts in a single play like this. Any advice / suggestions anyone has to accomplish this task would be appreciated.
