# Change SSH Port and User

**URL:** <https://forum.ansible.com/t/change-ssh-port-and-user/37236>\
**Category:** Ansible Project\
**Created:** [October 16, 2022, 9:41pm UTC](https://forum.ansible.com/t/change-ssh-port-and-user/37236 "2022-10-16T21:41:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Silvio\_Siefke](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@Silvio\_Siefke](https://forum.ansible.com/u/Silvio_Siefke)\
**Post date:** [October 16, 2022, 9:41pm UTC](https://forum.ansible.com/t/change-ssh-port-and-user/37236/1 "2022-10-16T21:41:29Z")

</div>

Hello,

I try to run a deployment Playbook with some roles like bootstraping, user and ssh server.  
The configuration for hosts I put in host\_vars folder.

The host file:

ansible\_user: "vagrant"  
ansible\_pass: "vagrant"  
ansible\_ssh\_pass: "vagrant"  
ansible\_become\_pass: "vagrant"  
ansible\_port: "22"

The playbook:

- name: Deploy the server  
hosts: vb\_deb  
become: yes  
gather\_facts: yes  
strategy: free  
tasks:  
- name: Let us bootstraping the server  
ansible.builtin.include\_role:  
name: core\_bootstrap  
- name: Let us install core packages  
ansible.builtin.include\_role:  
name: core\_packages  
- name: Let us create the user on server  
ansible.builtin.include\_role:  
name: core\_users  
- name: Let us install and configure the OpenSSH Server  
ansible.builtin.include\_role:  
name: core\_openssh

So now I had the problem the ssh user and the ssh port change to my username and 12000 for SSH.

How can I delete the variables (ansible\_pass, ansible\_ssh\_pass, ansible\_become\_pass, ansible\_port) in  
host\_vars file with ansible so that the default settings be used and I can run the next role?

Thank you for help.

Silvio

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 17, 2022, 5:39pm UTC](https://forum.ansible.com/t/change-ssh-port-and-user/37236/2 "2022-10-17T17:39:39Z")

</div>

I would put the variable sin the bootstrapping play instead, once the  
play runs out of scope (next play) the variables will be gone.
