# Hosts behind ssh-proxy

**URL:** <https://forum.ansible.com/t/hosts-behind-ssh-proxy/27399>\
**Category:** Ansible Project\
**Created:** [April 27, 2018, 7:08pm UTC](https://forum.ansible.com/t/hosts-behind-ssh-proxy/27399 "2018-04-27T19:08:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefan73er](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@stefan73er](https://forum.ansible.com/u/stefan73er)\
**Post date:** [April 27, 2018, 7:08pm UTC](https://forum.ansible.com/t/hosts-behind-ssh-proxy/27399/1 "2018-04-27T19:08:29Z")

</div>

Hi,  
i am new to using ansible but i am excited about it.  
Ansible is so powerful but one thing would make implementation easier for me.

I have some servers I need to connect to via an ssh-proxy.

So far I have not managed to make this possible with ansible.

The connection is done by ssh/scp according to the following pattern:

ssh %%@

Anybody have any idea how to do this with ansible?

Cheers,  
Stefan

---

<div class="post-metadata">

**Author:** ![stefan73er](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@stefan73er](https://forum.ansible.com/u/stefan73er)\
**Post date:** [April 28, 2018, 11:19am UTC](https://forum.ansible.com/t/hosts-behind-ssh-proxy/27399/2 "2018-04-28T11:19:10Z")

</div>

there was a mistake in the ssh command example. The right one is:

ssh %%@

---

<div class="post-metadata">

**Author:** ![Benny\_Kusman](https://avatars.discourse-cdn.com/v4/letter/b/4da419/32.png) [@Benny\_Kusman](https://forum.ansible.com/u/Benny_Kusman)\
**Post date:** [April 28, 2018, 3:28pm UTC](https://forum.ansible.com/t/hosts-behind-ssh-proxy/27399/3 "2018-04-28T15:28:17Z")

</div>

try this:  
[https://groups.google.com/forum/?utm\_medium=email&utm\_source=footer#!msg/ansible-project/-AFEyk69T8k/0X9skiOXCQAJ](https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/ansible-project/-AFEyk69T8k/0X9skiOXCQAJ)

---

<div class="post-metadata">

**Author:** ![Richard\_Hector](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@Richard\_Hector](https://forum.ansible.com/u/Richard_Hector)\
**Post date:** [April 28, 2018, 3:51pm UTC](https://forum.ansible.com/t/hosts-behind-ssh-proxy/27399/4 "2018-04-28T15:51:59Z")

</div>

> try this:  
> [https://groups.google.com/forum/?utm\_medium=email&utm\_source=footer#!msg/ansible-project/-AFEyk69T8k/0X9skiOXCQAJ](https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/ansible-project/-AFEyk69T8k/0X9skiOXCQAJ)

Or if you have a recent enough OpenSSH (7.3), you can use ProxyJump,  
which is much simpler:

# from  
# [https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Proxies\_and\_Jump\_Hosts](https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Proxies_and_Jump_Hosts)

# .ssh/config  
Host server2  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HostName 192.168.5.38  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ProxyJump user1@jumphost1.example.org:22  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;User fred

Richard

---

<div class="post-metadata">

**Author:** ![stefan73er](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@stefan73er](https://forum.ansible.com/u/stefan73er)\
**Post date:** [May 2, 2018, 6:02pm UTC](https://forum.ansible.com/t/hosts-behind-ssh-proxy/27399/5 "2018-05-02T18:02:24Z")

</div>

thanks for these suggestions but both seems not work for me.

What i call ssh-proxy does some more magic as a normal jump host.

On the proxy runs a ssh daemon that authenticates against ActiveDirectory and it has a connection to a password-safe.  
If i open a connection from my client to a server ([user1@myserver.example.com](mailto:user1@myserver.example.com)) i use the command:

ssh AD-User%user1%[myserver.example.com](http://myserver.example.com)@ssh-proxy.example.com

At the following password prompt i have to type in my AD-Password. The Proxy check if my AD-User is allowed to connect to [myserver.example.com](http://myserver.example.com) with user1.  
If it is allowed it gets the password for [user1@myserver.example.com](mailto:user1@myserver.example.com) out of the password-safe and use it to connect me to the server.  
I don´t know and i don´t need to know the real password. It is completely managed by the password-safe.

I think what i need to do is to get ansible to pass the string

AD-User%user1%[myserver.example.com](http://myserver.example.com) (AD-User%RemoteUser%RemoteHost)

as the Username for a connection to [ssh-proxy.example.com](http://ssh-proxy.example.com)

My first idea was to do this in the inventory file like this:

[myserver]  
[myserver.example.com](http://myserver.example.com)  
[myserver:vars]  
ansible\_user=AD-User%user1%[myserver.example.com](http://myserver.example.com)  
ansible\_host=[ssh-proxy.example.com](http://ssh-proxy.example.com)

But it does not work.  
Does anyone have another idea?

Stefan
